[PATCH] D113230: [WebAssembly] Fix fixBrTableIndex removing instruction without checking uses
Wouter van Oortmerssen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 8 12:29:51 PST 2021
aardappel updated this revision to Diff 385595.
aardappel added a comment.
Simplified using `use_nodbg_empty`
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113230/new/
https://reviews.llvm.org/D113230
Files:
llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
Index: llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
@@ -61,9 +61,13 @@
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 =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113230.385595.patch
Type: text/x-patch
Size: 990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211108/75591336/attachment.bin>
More information about the llvm-commits
mailing list