summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorAditya Nandakumar <aditya_nandakumar@apple.com>2017-05-17 17:41:55 +0000
committerAditya Nandakumar <aditya_nandakumar@apple.com>2017-05-17 17:41:55 +0000
commitbe9299371038c881248296a2051b66c977dbd419 (patch)
tree6d8a35e661c52861652d200596bf0025c30235f3 /llvm/lib/CodeGen
parent3f55f7e02d447bdbf6500840e85bb6dd8a72516c (diff)
downloadbcm5719-llvm-be9299371038c881248296a2051b66c977dbd419.tar.gz
bcm5719-llvm-be9299371038c881248296a2051b66c977dbd419.zip
[GISel]: Fix undefined behavior in IRTranslator
Make sure IRTranslator->MachineIRBuilder->DebugLoc doesn't outlive the DILocation. Clear it at the end of IRTranslator::runOnMachineFunction llvm-svn: 303277
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 811858f136e..77dfb13ac1f 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -1129,6 +1129,11 @@ void IRTranslator::finalizeFunction() {
ValToVReg.clear();
FrameIndices.clear();
MachinePreds.clear();
+ // MachineIRBuilder::DebugLoc can outlive the DILocation it holds. Clear it
+ // to avoid accessing free’d memory (in runOnMachineFunction) and to avoid
+ // destroying it twice (in ~IRTranslator() and ~LLVMContext())
+ EntryBuilder = MachineIRBuilder();
+ CurBuilder = MachineIRBuilder();
}
bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {
OpenPOWER on IntegriCloud