27 if (
MI.isMetaInstruction() ||
MI.isTerminator())
31 for (
unsigned i = 0; i <
MI.getNumOperands(); i++) {
51 "Hash function must be stable");
53 "Hash function must be stable");
54static_assert(
fold_64_to_16(1) == 1,
"Fold function must be stable");
55static_assert(
fold_64_to_16(12345678) == 25074,
"Fold function must be stable");
58 "Machine Block Hash Analysis",
true,
true)
84 auto &HashInfo = HashInfos[&
MBB];
95 auto &HashInfo = HashInfos[&
MBB];
99 uint64_t SuccHash = HashInfos[SuccMBB].OpcodeHash;
104 uint64_t PredHash = HashInfos[PredMBB].OpcodeHash;
107 HashInfo.NeighborHash = Hash;
112 const auto &HashInfo = HashInfos[&
MBB];
123 auto it = MBBHashInfo.find(&
MBB);
133 return Result.getMBBHash(
MBB);
152 OS <<
"Machine Block Hash Info for function: " << MF.
getName() <<
"\n";
153 for (
const auto &
MBB : MF) {
154 OS <<
" BB#" <<
MBB.getNumber() <<
": "
static constexpr uint16_t fold_64_to_16(const uint64_t Value)
Fold a 64-bit integer to a 16-bit one.
static uint64_t hashBlock(const MachineBasicBlock &MBB, bool HashOperands)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Result object for MachineBlockHashInfo.
MachineBlockHashInfoResult()
uint64_t getMBBHash(const MachineBasicBlock &MBB) const
Legacy MachineFunctionPass for MachineBlockHashInfo.
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
uint64_t getMBBHash(const MachineBasicBlock &MBB) const
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Representation of each machine instruction.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
LLVM Value Representation.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
constexpr uint64_t hash_16_bytes(uint64_t low, uint64_t high)
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI stable_hash stableHashValue(const MachineOperand &MO)
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
LLVM_ABI MachineFunctionPass * createMachineBlockHashInfoPass()
createMachineBlockHashInfoPass - This pass computes basic block hashes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
An object wrapping several components of a basic block hash.
uint64_t combine() const
Combine the blended hash into uint64_t.