[llvm] 435d44b - [VE][NFC] Fix use-after-free in VEInstrInfo
Simon Moll via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 1 10:32:13 PST 2021
Author: Simon Moll
Date: 2021-12-01T19:30:27+01:00
New Revision: 435d44bf8ab3925b85b70c0736841e3c4c667199
URL: https://github.com/llvm/llvm-project/commit/435d44bf8ab3925b85b70c0736841e3c4c667199
DIFF: https://github.com/llvm/llvm-project/commit/435d44bf8ab3925b85b70c0736841e3c4c667199.diff
LOG: [VE][NFC] Fix use-after-free in VEInstrInfo
First call getOperand, then erase the MachineInstr. Not the other way
round.
Expected to fix test/CodeGen/VE/VELIntrinsics/lvm.ll
Detected by asan buildbot:
sanitizer-x86_64-linux-fast
(https://lab.llvm.org/buildbot/#/builders/5/builds/15384)
Added:
Modified:
llvm/lib/Target/VE/VEInstrInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/VE/VEInstrInfo.cpp b/llvm/lib/Target/VE/VEInstrInfo.cpp
index ddcfb9da8249..0624651ed03d 100644
--- a/llvm/lib/Target/VE/VEInstrInfo.cpp
+++ b/llvm/lib/Target/VE/VEInstrInfo.cpp
@@ -942,11 +942,11 @@ bool VEInstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
MachineInstrBuilder MIB =
BuildMI(*MBB, MI, DL, get(VE::SVMmi), Dest).addReg(VMZ).addImm(Imm);
MachineInstr *Inst = MIB.getInstr();
- MI.eraseFromParent();
if (KillSrc) {
const TargetRegisterInfo *TRI = &getRegisterInfo();
Inst->addRegisterKilled(MI.getOperand(1).getReg(), TRI, true);
}
+ MI.eraseFromParent();
return true;
}
case VE::VFMKyal:
More information about the llvm-commits
mailing list