[PATCH] D37789: ThinLTO: Correctly follow aliasee references when dead stripping.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 10:10:56 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL313157: ThinLTO: Correctly follow aliasee references when dead stripping. (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D37789?vs=114962&id=115066#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37789

Files:
  llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
  llvm/trunk/test/LTO/Resolution/X86/Inputs/dead-strip-alias.ll
  llvm/trunk/test/LTO/Resolution/X86/dead-strip-alias.ll


Index: llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
@@ -488,17 +488,14 @@
   while (!Worklist.empty()) {
     auto VI = Worklist.pop_back_val();
     for (auto &Summary : VI.getSummaryList()) {
-      for (auto Ref : Summary->refs())
+      GlobalValueSummary *Base = Summary.get();
+      if (auto *AS = dyn_cast<AliasSummary>(Base))
+        Base = &AS->getAliasee();
+      for (auto Ref : Base->refs())
         visit(Ref);
-      if (auto *FS = dyn_cast<FunctionSummary>(Summary.get()))
+      if (auto *FS = dyn_cast<FunctionSummary>(Base))
         for (auto Call : FS->calls())
           visit(Call.first);
-      if (auto *AS = dyn_cast<AliasSummary>(Summary.get())) {
-        auto AliaseeGUID = AS->getAliasee().getOriginalName();
-        ValueInfo AliaseeVI = Index.getValueInfo(AliaseeGUID);
-        if (AliaseeVI)
-          visit(AliaseeVI);
-      }
     }
   }
   Index.setWithGlobalValueDeadStripping();
Index: llvm/trunk/test/LTO/Resolution/X86/dead-strip-alias.ll
===================================================================
--- llvm/trunk/test/LTO/Resolution/X86/dead-strip-alias.ll
+++ llvm/trunk/test/LTO/Resolution/X86/dead-strip-alias.ll
@@ -0,0 +1,20 @@
+; RUN: opt -module-summary -o %t %s
+; RUN: opt -module-summary -o %t2 %S/Inputs/dead-strip-alias.ll
+; RUN: llvm-lto2 run %t -r %t,main,px -r %t,alias,p -r %t,external, \
+; RUN:               %t2 -r %t2,external,p \
+; RUN: -save-temps -o %t3
+; RUN: llvm-nm %t3.1 | FileCheck %s
+
+; CHECK: D external
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at alias = alias i8*, i8** @internal
+
+ at internal = internal global i8* @external
+ at external = external global i8
+
+define i8** @main() {
+  ret i8** @alias
+}
Index: llvm/trunk/test/LTO/Resolution/X86/Inputs/dead-strip-alias.ll
===================================================================
--- llvm/trunk/test/LTO/Resolution/X86/Inputs/dead-strip-alias.ll
+++ llvm/trunk/test/LTO/Resolution/X86/Inputs/dead-strip-alias.ll
@@ -0,0 +1,4 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at external = global i8 42


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37789.115066.patch
Type: text/x-patch
Size: 2361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170913/b0fb02f0/attachment.bin>


More information about the llvm-commits mailing list