Skip to content

Commit

Permalink
[WebAssembly] Fix fixBrTableIndex removing instruction without checki…
Browse files Browse the repository at this point in the history
  • Loading branch information
aardappel authored and nikic committed Nov 9, 2021
1 parent a7348ae commit b51341b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit b51341b

Please sign in to comment.