forked from OSchip/llvm-project
[StableHashing] Hash machine basic blocks and functions
This adds very basic support for hashing MachineBasicBlock and MachineFunction, for use in MachineFunctionPass to detect passes that modify the MachineFunction wrongly. Differential Revision: https://reviews.llvm.org/D120122
This commit is contained in:
parent
0e74d75a29
commit
b47e2dc91f
|
@ -17,6 +17,8 @@
|
|||
#include "llvm/CodeGen/StableHashing.h"
|
||||
|
||||
namespace llvm {
|
||||
class MachineBasicBlock;
|
||||
class MachineFunction;
|
||||
class MachineInstr;
|
||||
class MachineOperand;
|
||||
|
||||
|
@ -24,6 +26,8 @@ stable_hash stableHashValue(const MachineOperand &MO);
|
|||
stable_hash stableHashValue(const MachineInstr &MI, bool HashVRegs = false,
|
||||
bool HashConstantPoolIndices = false,
|
||||
bool HashMemOperands = false);
|
||||
stable_hash stableHashValue(const MachineBasicBlock &MBB);
|
||||
stable_hash stableHashValue(const MachineFunction &MF);
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
|
|
|
@ -195,3 +195,21 @@ stable_hash llvm::stableHashValue(const MachineInstr &MI, bool HashVRegs,
|
|||
return stable_hash_combine_range(HashComponents.begin(),
|
||||
HashComponents.end());
|
||||
}
|
||||
|
||||
stable_hash llvm::stableHashValue(const MachineBasicBlock &MBB) {
|
||||
SmallVector<stable_hash> HashComponents;
|
||||
// TODO: Hash more stuff like block alignment and branch probabilities.
|
||||
for (auto &MI : MBB)
|
||||
HashComponents.push_back(stableHashValue(MI));
|
||||
return stable_hash_combine_range(HashComponents.begin(),
|
||||
HashComponents.end());
|
||||
}
|
||||
|
||||
stable_hash llvm::stableHashValue(const MachineFunction &MF) {
|
||||
SmallVector<stable_hash> HashComponents;
|
||||
// TODO: Hash lots more stuff like function alignment and stack objects.
|
||||
for (auto &MBB : MF)
|
||||
HashComponents.push_back(stableHashValue(MBB));
|
||||
return stable_hash_combine_range(HashComponents.begin(),
|
||||
HashComponents.end());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue