[PATCH] D36919: [ThinLTO] Fix ThinLTO crash

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 19 11:05:38 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL311254: [ThinLTO] Fix ThinLTO crash (authored by tejohnson).

Repository:
  rL LLVM

https://reviews.llvm.org/D36919

Files:
  llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
  llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport_var2.ll
  llvm/trunk/test/Transforms/FunctionImport/funcimport_var.ll


Index: llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
@@ -129,6 +129,21 @@
       CalleeSummaryList,
       [&](const std::unique_ptr<GlobalValueSummary> &SummaryPtr) {
         auto *GVSummary = SummaryPtr.get();
+        // For SamplePGO, in computeImportForFunction the OriginalId
+        // may have been used to locate the callee summary list (See
+        // comment there).
+        // The mapping from OriginalId to GUID may return a GUID
+        // that corresponds to a static variable. Filter it out here.
+        // This can happen when
+        // 1) There is a call to a library function which is not defined
+        // in the index.
+        // 2) There is a static variable with the  OriginalGUID identical
+        // to the GUID of the library function in 1);
+        // When this happens, the logic for SamplePGO kicks in and
+        // the static variable in 2) will be found, which needs to be
+        // filtered out.
+        if (GVSummary->getSummaryKind() == GlobalValueSummary::GlobalVarKind)
+          return false;
         if (GlobalValue::isInterposableLinkage(GVSummary->linkage()))
           // There is no point in importing these, we can't inline them
           return false;
Index: llvm/trunk/test/Transforms/FunctionImport/funcimport_var.ll
===================================================================
--- llvm/trunk/test/Transforms/FunctionImport/funcimport_var.ll
+++ llvm/trunk/test/Transforms/FunctionImport/funcimport_var.ll
@@ -4,6 +4,18 @@
 ; RUN: opt -module-summary %p/Inputs/funcimport_var2.ll -o %t2.bc
 ; RUN: llvm-lto -thinlto -thinlto-action=thinlink -o %t3 %t.bc %t2.bc
 ; RUN: llvm-lto -thinlto -thinlto-action=import -thinlto-index=%t3 %t.bc %t2.bc
+; RUN: llvm-lto -thinlto -thinlto-action=run %t.bc %t2.bc
+; RUN: llvm-nm %t.bc.thinlto.o | FileCheck %s
+; RUN: llvm-lto2 run %t.bc %t2.bc -o %t.out \
+; RUN:   -r %t.bc,_Z4LinkPKcS0_,plx \
+; RUN:   -r %t.bc,link,l \
+; RUN:   -r %t2.bc,get_link,plx
+; RUN: llvm-nm %t.out.0 | FileCheck %s
+; CHECK: U link
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
 define i32 @_Z4LinkPKcS0_(i8*, i8*) local_unnamed_addr  {
   %3 = tail call i32 @link(i8* %0, i8* %1) #2
   ret i32 %3
Index: llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport_var2.ll
===================================================================
--- llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport_var2.ll
+++ llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport_var2.ll
@@ -1,3 +1,6 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
 @link = internal global i32 0, align 4
 
 ; Function Attrs: norecurse nounwind readnone uwtable


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36919.111847.patch
Type: text/x-patch
Size: 2941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170819/83c4880c/attachment.bin>


More information about the llvm-commits mailing list