[llvm] 4a0c89a - [WebAssembly] Fix fixBrTableIndex removing instruction without checking uses
Wouter van Oortmerssen via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 8 15:54:04 PST 2021
Author: Wouter van Oortmerssen
Date: 2021-11-08T15:53:44-08:00
New Revision: 4a0c89a6cf8f368583f9c0724dbcb04fb17204ec
URL: https://github.com/llvm/llvm-project/commit/4a0c89a6cf8f368583f9c0724dbcb04fb17204ec
DIFF: https://github.com/llvm/llvm-project/commit/4a0c89a6cf8f368583f9c0724dbcb04fb17204ec.diff
LOG: [WebAssembly] Fix fixBrTableIndex removing instruction without checking uses
Fixes: https://bugs.llvm.org/show_bug.cgi?id=52352
Differential Revision: https://reviews.llvm.org/D113230
Added:
Modified:
llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
index 52aa3534c78ef..5bdec89f1125f 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
@@ -61,9 +61,13 @@ void fixBrTableIndex(MachineInstr &MI, MachineBasicBlock *MBB,
auto ExtMI = MF.getRegInfo().getVRegDef(MI.getOperand(0).getReg());
if (ExtMI->getOpcode() == WebAssembly::I64_EXTEND_U_I32) {
// Unnecessarily extending a 32-bit value to 64, remove it.
- assert(MI.getOperand(0).getReg() == ExtMI->getOperand(0).getReg());
+ auto ExtDefReg = ExtMI->getOperand(0).getReg();
+ assert(MI.getOperand(0).getReg() == ExtDefReg);
MI.getOperand(0).setReg(ExtMI->getOperand(1).getReg());
- ExtMI->eraseFromParent();
+ if (MF.getRegInfo().use_nodbg_empty(ExtDefReg)) {
+ // No more users of extend, delete it.
+ ExtMI->eraseFromParent();
+ }
} else {
// Incoming 64-bit value that needs to be truncated.
Register Reg32 =
More information about the llvm-commits
mailing list