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

Charles Saternos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 11:40:59 PDT 2017


ncharlie created this revision.
ncharlie added a project: lld.
Herald added subscribers: inglorion, Prazek, mehdi_amini.

[ThinLTO] Fix ThinLTO crash while destroying context

Fix for PR32763

An assert that checks if a Ref was untracked fails during ThinLTO context cleanup. The issue is because lazy loading temporary nodes didn't properly track ValueAsMetadata nodes. This patch ensures that the temporary nodes are properly tracked when they're replaced with the value.


Repository:
  rL LLVM

https://reviews.llvm.org/D33513

Files:
  include/llvm/IR/Metadata.h
  test/Linker/Inputs/lazy-load-temporaries-cleanup.a.ll
  test/Linker/Inputs/lazy-load-temporaries-cleanup.b.ll
  test/Linker/lazy-load-temporaries-cleanup.ll


Index: test/Linker/lazy-load-temporaries-cleanup.ll
===================================================================
--- test/Linker/lazy-load-temporaries-cleanup.ll
+++ test/Linker/lazy-load-temporaries-cleanup.ll
@@ -0,0 +1,5 @@
+; This test ensures that metadata temporaries are properly tracked, then cleaned up
+
+; RUN: opt -module-summary %S/Inputs/lazy-load-temporaries-cleanup.a.ll -o %t.1.o
+; RUN: opt -module-summary %S/Inputs/lazy-load-temporaries-cleanup.b.ll -o %t.2.o
+; RUN: llvm-link %t.1.o %t.2.o
Index: test/Linker/Inputs/lazy-load-temporaries-cleanup.b.ll
===================================================================
--- test/Linker/Inputs/lazy-load-temporaries-cleanup.b.ll
+++ test/Linker/Inputs/lazy-load-temporaries-cleanup.b.ll
@@ -0,0 +1,20 @@
+define void  @patatino() {
+  ret void
+}
+
+!llvm.asan.globals = !{!0, !2, !4, !6, !8, !10, !12}
+
+!0  =  distinct !{!1}
+!1  = !{i8 1}
+!2  =  distinct !{!3}
+!3  = !{i8 2}
+!4  =  distinct !{!5}
+!5  = !{i8 3}
+!6  =  distinct !{!7}
+!7  = !{i8 4,  i8 5}
+!8  =  distinct !{!9}
+!9  = !{i8 6,  i8 7}
+!10 =  distinct !{!11}
+!11 = !{i8 8,  i8 9}
+!12 =  distinct !{!13, i8 0}
+!13 = !{i8 10, i8 11}
Index: test/Linker/Inputs/lazy-load-temporaries-cleanup.a.ll
===================================================================
--- test/Linker/Inputs/lazy-load-temporaries-cleanup.a.ll
+++ test/Linker/Inputs/lazy-load-temporaries-cleanup.a.ll
@@ -0,0 +1,6 @@
+define void @tinkywinky() {
+  tail call void @patatino()
+  ret void
+}
+
+declare void @patatino()
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.100119.patch
Type: text/x-patch
Size: 1861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170524/4ed806b1/attachment.bin>


More information about the llvm-commits mailing list