aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineOperand.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2024-10-22 13:48:00 -0700
committerGitHub <noreply@github.com>2024-10-22 13:48:00 -0700
commit5c92f2331c7e02059baddaa3eaf35c039a48caf2 (patch)
treeddf01f3a26d385ce42d5dfaa382d159294ba63b7 /llvm/lib/CodeGen/MachineOperand.cpp
parent71792dc570c5b0eca0937efbd57d9ea1457dc87f (diff)
downloadllvm-5c92f2331c7e02059baddaa3eaf35c039a48caf2.zip
llvm-5c92f2331c7e02059baddaa3eaf35c039a48caf2.tar.gz
llvm-5c92f2331c7e02059baddaa3eaf35c039a48caf2.tar.bz2
[WebAssembly] Fix MIR printing of reference types (#113028)
When printing a memory operand in MIR, this line https://github.com/llvm/llvm-project/blob/d37bc32a65651e647148236ffb9728ea2e77eac3/llvm/lib/CodeGen/MachineOperand.cpp#L1247 calls this https://github.com/llvm/llvm-project/blob/d37bc32a65651e647148236ffb9728ea2e77eac3/llvm/include/llvm/Support/Alignment.h#L238 which assumes `Rhs` (the size in this case) is positive. But Wasm reference types' size is set to 0: https://github.com/llvm/llvm-project/blob/d37bc32a65651e647148236ffb9728ea2e77eac3/llvm/include/llvm/CodeGen/ValueTypes.td#L326-L328 `getSize() > 0` condition was added with the Wasm reference types support in https://github.com/llvm/llvm-project/commit/46667a10039b664b953eb70534c27627b35a267d, and it looks it was removed in #84751. This revives the condition so that Wasm reference types will not crash the MIR printer.
Diffstat (limited to 'llvm/lib/CodeGen/MachineOperand.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineOperand.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp
index 89d32c3..c0e0045 100644
--- a/llvm/lib/CodeGen/MachineOperand.cpp
+++ b/llvm/lib/CodeGen/MachineOperand.cpp
@@ -1244,7 +1244,8 @@ void MachineMemOperand::print(raw_ostream &OS, ModuleSlotTracker &MST,
}
MachineOperand::printOperandOffset(OS, getOffset());
if (!getSize().hasValue() ||
- getAlign() != getSize().getValue().getKnownMinValue())
+ (!getSize().isZero() &&
+ getAlign() != getSize().getValue().getKnownMinValue()))
OS << ", align " << getAlign().value();
if (getAlign() != getBaseAlign())
OS << ", basealign " << getBaseAlign().value();