[PATCH] D133637: Bug fix on stable hash calculation for machine operands RegisterMask and RegisterLiveOut
Kyungwoo Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 12 13:26:01 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG481a32f58745: Bug fix on stable hash calculation for machine operands RegisterMask and… (authored by yozhu, committed by kyulee).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133637/new/
https://reviews.llvm.org/D133637
Files:
llvm/include/llvm/CodeGen/MachineOperand.h
llvm/lib/CodeGen/MachineOperand.cpp
llvm/lib/CodeGen/MachineStableHash.cpp
Index: llvm/lib/CodeGen/MachineStableHash.cpp
===================================================================
--- llvm/lib/CodeGen/MachineStableHash.cpp
+++ llvm/lib/CodeGen/MachineStableHash.cpp
@@ -119,8 +119,20 @@
stable_hash_combine_string(MO.getSymbolName()));
case MachineOperand::MO_RegisterMask:
- case MachineOperand::MO_RegisterLiveOut:
- return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getRegMask());
+ case MachineOperand::MO_RegisterLiveOut: {
+ const uint32_t *RegMask = MO.getRegMask();
+ const unsigned RegMaskSize = MO.getRegMaskSize();
+
+ if (RegMaskSize != 0) {
+ std::vector<llvm::stable_hash> RegMaskHashes(RegMask,
+ RegMask + RegMaskSize);
+ return hash_combine(MO.getType(), MO.getTargetFlags(),
+ stable_hash_combine_array(RegMaskHashes.data(),
+ RegMaskHashes.size()));
+ }
+
+ return hash_combine(MO.getType(), MO.getTargetFlags());
+ }
case MachineOperand::MO_ShuffleMask: {
std::vector<llvm::stable_hash> ShuffleMaskHashes;
Index: llvm/lib/CodeGen/MachineOperand.cpp
===================================================================
--- llvm/lib/CodeGen/MachineOperand.cpp
+++ llvm/lib/CodeGen/MachineOperand.cpp
@@ -279,6 +279,17 @@
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.
@@ -322,11 +333,8 @@
if (RegMask == OtherRegMask)
return true;
- if (const MachineFunction *MF = getMFIfAvailable(*this)) {
- // Calculate the size of the RegMask
- const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
- unsigned RegMaskSize = (TRI->getNumRegs() + 31) / 32;
-
+ const unsigned RegMaskSize = getRegMaskSize();
+ if (RegMaskSize != 0) {
// Deep compare of the two RegMasks
return std::equal(RegMask, RegMask + RegMaskSize, OtherRegMask);
}
Index: llvm/include/llvm/CodeGen/MachineOperand.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineOperand.h
+++ llvm/include/llvm/CodeGen/MachineOperand.h
@@ -641,6 +641,10 @@
return Contents.RegMask;
}
+ /// Return the size of regmask array if we are able to figure it out from
+ /// this operand. Return zero otherwise.
+ unsigned getRegMaskSize() const;
+
/// Returns number of elements needed for a regmask array.
static unsigned getRegMaskSize(unsigned NumRegs) {
return (NumRegs + 31) / 32;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133637.459546.patch
Type: text/x-patch
Size: 3130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220912/fa666910/attachment.bin>
More information about the llvm-commits
mailing list