Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 3c60df7

Browse files
committed
[ThinLTO] Remove too aggressive assertion in building function call graph.
The assertion was introduced in r317853 but there are cases when a call isn't handled either as direct or indirect. In this case we add a reference graph edge but not a call graph edge. Reviewers: tejohnson Reviewed By: tejohnson Subscribers: mehdi_amini, inglorion, eraman, hiraditya, efriedma, llvm-commits Differential Revision: https://reviews.llvm.org/D40056 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318540 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 39107fc commit 3c60df7

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/Analysis/ModuleSummaryAnalysis.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,9 @@ computeFunctionSummary(ModuleSummaryIndex &Index, const Module &M,
280280
// Skip inline assembly calls.
281281
if (CI && CI->isInlineAsm())
282282
continue;
283-
assert(CalledValue && !isa<Constant>(CalledValue) &&
284-
"Expected indirect call");
283+
// Skip direct calls.
284+
if (!CalledValue || isa<Constant>(CalledValue))
285+
continue;
285286

286287
uint32_t NumVals, NumCandidates;
287288
uint64_t TotalCount;

test/Bitcode/thinlto-function-summary-callgraph-cast.ll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
; CHECK: <GLOBALVAL_SUMMARY_BLOCK
77
; CHECK-NEXT: <VERSION
8-
; "op7=1" is a call to "callee" function.
9-
; CHECK-NEXT: <PERMODULE {{.*}} op7=1 op8=[[ALIASID:[0-9]+]]/>
8+
; "op7" is a call to "callee" function.
9+
; CHECK-NEXT: <PERMODULE {{.*}} op7=3 op8=[[ALIASID:[0-9]+]]/>
10+
; "another_caller" has only references but no calls.
11+
; CHECK-NEXT: <PERMODULE {{.*}} op4=3 {{.*}} op7={{[0-9]+}}/>
1012
; CHECK-NEXT: <PERMODULE {{.*}} op0=[[ALIASEEID:[0-9]+]]
1113
; CHECK-NEXT: <ALIAS {{.*}} op0=[[ALIASID]] {{.*}} op2=[[ALIASEEID]]/>
1214
; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
@@ -21,6 +23,12 @@ define void @caller() {
2123
ret void
2224
}
2325

26+
define void @another_caller() {
27+
; Test calls that aren't handled either as direct or indirect.
28+
call void select (i1 icmp eq (i32* @global, i32* null), void ()* @f, void ()* @g)()
29+
ret void
30+
}
31+
2432
declare void @callee(...)
2533

2634
@analias = alias void (...), bitcast (void ()* @aliasee to void (...)*)
@@ -29,3 +37,7 @@ define void @aliasee() {
2937
entry:
3038
ret void
3139
}
40+
41+
declare void @f()
42+
declare void @g()
43+
@global = extern_weak global i32

0 commit comments

Comments
 (0)