[PATCH] D33513: [ThinLTO] Fix ThinLTO crash while destroying context

Charles Saternos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 29 09:50:42 PDT 2017


ncharlie updated this revision to Diff 100620.
ncharlie added a comment.

Simplified test


https://reviews.llvm.org/D33513

Files:
  include/llvm/IR/Metadata.h
  test/ThinLTO/X86/Inputs/lazy-load-temporaries-cleanup.b.ll
  test/ThinLTO/X86/lazy-load-temporaries-cleanup.ll
  tools/llvm-dis/llvm-dis.cpp


Index: tools/llvm-dis/llvm-dis.cpp
===================================================================
--- tools/llvm-dis/llvm-dis.cpp
+++ tools/llvm-dis/llvm-dis.cpp
@@ -144,7 +144,7 @@
       ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename)));
   std::unique_ptr<Module> M =
       ExitOnErr(getOwningLazyBitcodeModule(std::move(MB), Context,
-                                           /*ShouldLazyLoadMetadata=*/true));
+                                           /*ShouldLazyLoadMetadata=*/true, true));
   if (MaterializeMetadata)
     ExitOnErr(M->materializeMetadata());
   else
Index: test/ThinLTO/X86/lazy-load-temporaries-cleanup.ll
===================================================================
--- test/ThinLTO/X86/lazy-load-temporaries-cleanup.ll
+++ test/ThinLTO/X86/lazy-load-temporaries-cleanup.ll
@@ -0,0 +1,4 @@
+; This test ensures that metadata temporaries are properly tracked, then cleaned up
+
+; RUN: opt -module-summary -bitcode-mdindex-threshold=0 %S/Inputs/lazy-load-temporaries-cleanup.b.ll -o %t.2.o
+; RUN: llvm-dis -materialize-metadata %t.2.o
Index: test/ThinLTO/X86/Inputs/lazy-load-temporaries-cleanup.b.ll
===================================================================
--- test/ThinLTO/X86/Inputs/lazy-load-temporaries-cleanup.b.ll
+++ test/ThinLTO/X86/Inputs/lazy-load-temporaries-cleanup.b.ll
@@ -0,0 +1,11 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void  @patatino() {
+  ret void
+}
+
+!named = !{!0}
+
+!0  =  distinct !{!1, i8 0}
+!1  = !{i8 1}
Index: include/llvm/IR/Metadata.h
===================================================================
--- include/llvm/IR/Metadata.h
+++ include/llvm/IR/Metadata.h
@@ -1277,6 +1277,8 @@
     if (!Use)
       return;
     *Use = MD;
+    if(*Use)
+      MetadataTracking::track(*Use);
     Use = nullptr;
   }
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33513.100620.patch
Type: text/x-patch
Size: 1908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170529/67379cab/attachment.bin>


More information about the llvm-commits mailing list