diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineOperand.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineOperand.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp index 7a85eaf..393a4f7 100644 --- a/llvm/lib/CodeGen/MachineOperand.cpp +++ b/llvm/lib/CodeGen/MachineOperand.cpp @@ -18,6 +18,7 @@ #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/StableHashing.h" #include "llvm/CodeGen/TargetInstrInfo.h" #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/Config/llvm-config.h" @@ -45,6 +46,7 @@ static const MachineFunction *getMFIfAvailable(const MachineOperand &MO) { return MF; return nullptr; } + static MachineFunction *getMFIfAvailable(MachineOperand &MO) { return const_cast<MachineFunction *>( getMFIfAvailable(const_cast<const MachineOperand &>(MO))); @@ -279,17 +281,6 @@ void MachineOperand::ChangeToRegister(Register Reg, bool isDef, bool isImp, RegInfo->addRegOperandToUseList(this); } -/// getRegMaskSize - Return the size of regmask array if we are able to figure -/// it out from this operand. Return zero otherwise. -unsigned MachineOperand::getRegMaskSize() const { - if (const MachineFunction *MF = getMFIfAvailable(*this)) { - const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); - unsigned RegMaskSize = (TRI->getNumRegs() + 31) / 32; - return RegMaskSize; - } - return 0; -} - /// isIdenticalTo - Return true if this operand is identical to the specified /// operand. Note that this should stay in sync with the hash_value overload /// below. @@ -333,8 +324,9 @@ bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const { if (RegMask == OtherRegMask) return true; - const unsigned RegMaskSize = getRegMaskSize(); - if (RegMaskSize != 0) { + if (const MachineFunction *MF = getMFIfAvailable(*this)) { + const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); + unsigned RegMaskSize = MachineOperand::getRegMaskSize(TRI->getNumRegs()); // Deep compare of the two RegMasks return std::equal(RegMask, RegMask + RegMaskSize, OtherRegMask); } @@ -390,8 +382,20 @@ hash_code llvm::hash_value(const MachineOperand &MO) { return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getBlockAddress(), MO.getOffset()); case MachineOperand::MO_RegisterMask: - case MachineOperand::MO_RegisterLiveOut: - return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getRegMask()); + case MachineOperand::MO_RegisterLiveOut: { + if (const MachineFunction *MF = getMFIfAvailable(MO)) { + const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); + unsigned RegMaskSize = MachineOperand::getRegMaskSize(TRI->getNumRegs()); + const uint32_t *RegMask = MO.getRegMask(); + std::vector<stable_hash> RegMaskHashes(RegMask, RegMask + RegMaskSize); + return hash_combine(MO.getType(), MO.getTargetFlags(), + stable_hash_combine_array(RegMaskHashes.data(), + RegMaskHashes.size())); + } + + assert(0 && "MachineOperand not associated with any MachineFunction"); + return hash_combine(MO.getType(), MO.getTargetFlags()); + } case MachineOperand::MO_Metadata: return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getMetadata()); case MachineOperand::MO_MCSymbol: |