[PATCH] D33224: [GISel]: Fix more Undefined behavior in GlobalISel::IRTranslator

Aditya Nandakumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 14:24:04 PDT 2017


aditya_nandakumar updated this revision to Diff 99200.
aditya_nandakumar added a comment.

Updated comment based on Daniel's feedback.


https://reviews.llvm.org/D33224

Files:
  lib/CodeGen/GlobalISel/IRTranslator.cpp


Index: lib/CodeGen/GlobalISel/IRTranslator.cpp
===================================================================
--- lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -1129,6 +1129,11 @@
   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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33224.99200.patch
Type: text/x-patch
Size: 672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170516/17d78ae5/attachment.bin>


More information about the llvm-commits mailing list