forked from OSchip/llvm-project
[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
This commit is contained in:
parent
1297c21406
commit
4a0c89a6cf
|
@ -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 =
|
||||
|
|
Loading…
Reference in New Issue