[PATCH] D25384: [ThinLTO] Record references to aliases to calls
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 16:15:51 PDT 2016
tejohnson created this revision.
tejohnson added reviewers: davide, mehdi_amini.
tejohnson added a subscriber: llvm-commits.
When there is a call to an alias in the same module, we were not
adding either a reference or call edge. So we could incorrectly think
that the alias was dead if it was inlined in that function, despite
having a reference imported elsewhere. This resulted in unsats at
link time.
Add a reference edge when the call is to an alias, since we won't
add a call edge for it.
https://reviews.llvm.org/D25384
Files:
lib/Analysis/ModuleSummaryAnalysis.cpp
test/Bitcode/thinlto-alias2.ll
Index: test/Bitcode/thinlto-alias2.ll
===================================================================
--- /dev/null
+++ test/Bitcode/thinlto-alias2.ll
@@ -0,0 +1,28 @@
+; Test to check the callgraph for call to alias in module.
+; RUN: opt -module-summary %s -o %t.o
+; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
+
+; CHECK: <GLOBALVAL_SUMMARY_BLOCK
+; CHECK-NEXT: <VERSION
+; CHECK-NEXT: <PERMODULE {{.*}} op3=1 op4=[[ALIASID:[0-9]+]]/>
+; CHECK-NEXT: <PERMODULE {{.*}} op0=[[ALIASEEID:[0-9]+]]
+; CHECK-NEXT: <ALIAS {{.*}} op0=[[ALIASID]] {{.*}} op2=[[ALIASEEID]]/>
+; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
+
+; ModuleID = 'thinlto-alias2.ll'
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @main() {
+entry:
+ call void (...) @analias()
+ ret i32 0
+}
+
+ at analias = alias void (...), bitcast (void ()* @aliasee to void (...)*)
+
+define void @aliasee() #0 {
+entry:
+ ret void
+}
+
Index: lib/Analysis/ModuleSummaryAnalysis.cpp
===================================================================
--- lib/Analysis/ModuleSummaryAnalysis.cpp
+++ lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -55,7 +55,7 @@
// We have a reference to a global value. This should be added to
// the reference set unless it is a callee. Callees are handled
// specially by WriteFunction and are added to a separate list.
- if (!(CS && CS.isCallee(&OI)))
+ if (!(CS && CS.isCallee(&OI) && CS.getCalledFunction()))
RefEdges.insert(Operand);
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25384.74000.patch
Type: text/x-patch
Size: 1603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/1cdc56ad/attachment.bin>
More information about the llvm-commits
mailing list