diff options
author | Justin Bogner <mail@justinbogner.com> | 2016-03-25 18:38:48 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2016-03-25 18:38:48 +0000 |
commit | ec5ea36891ae3b755a59e309962f820968656da9 (patch) | |
tree | 9608861359e69c0ec16428d1b975c0ec9d66f846 | |
parent | f2a0d349a68cd6e3f94c34743b4adf1f1ce6730b (diff) | |
download | bcm5719-llvm-ec5ea36891ae3b755a59e309962f820968656da9.tar.gz bcm5719-llvm-ec5ea36891ae3b755a59e309962f820968656da9.zip |
CodeGen: Fix a use-after-free in TII
Found by ASAN with the recycling allocator changes from PR26808.
llvm-svn: 264443
-rw-r--r-- | llvm/lib/CodeGen/TargetInstrInfo.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp index eccd1e84306..86517d9afbc 100644 --- a/llvm/lib/CodeGen/TargetInstrInfo.cpp +++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp @@ -107,13 +107,15 @@ TargetInstrInfo::ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail, while (!MBB->succ_empty()) MBB->removeSuccessor(MBB->succ_begin()); + // Save off the debug loc before erasing the instruction. + DebugLoc DL = Tail->getDebugLoc(); + // Remove all the dead instructions from the end of MBB. MBB->erase(Tail, MBB->end()); // If MBB isn't immediately before MBB, insert a branch to it. if (++MachineFunction::iterator(MBB) != MachineFunction::iterator(NewDest)) - InsertBranch(*MBB, NewDest, nullptr, SmallVector<MachineOperand, 0>(), - Tail->getDebugLoc()); + InsertBranch(*MBB, NewDest, nullptr, SmallVector<MachineOperand, 0>(), DL); MBB->addSuccessor(NewDest); } |