summaryrefslogtreecommitdiffstats
path: root/llvm/test/Bitcode
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-03-11 18:52:24 +0000
committerTeresa Johnson <tejohnson@google.com>2016-03-11 18:52:24 +0000
commit76a1c1d0ba05993f3e57f935698ec0fd09b66c8c (patch)
treee89825099cc401c2546bbfa7e0ac83c2e1d98644 /llvm/test/Bitcode
parentc134810cfb91716554177992c4bbbf2543545a1a (diff)
downloadbcm5719-llvm-76a1c1d0ba05993f3e57f935698ec0fd09b66c8c.tar.gz
bcm5719-llvm-76a1c1d0ba05993f3e57f935698ec0fd09b66c8c.zip
[ThinLTO] Support for reference graph in per-module and combined summary.
Summary: This patch adds support for including a full reference graph including call graph edges and other GV references in the summary. The reference graph edges can be used to make importing decisions without materializing any source modules, can be used in the plugin to make file staging decisions for distributed build systems, and is expected to have other uses. The call graph edges are recorded in each function summary in the bitcode via a list of <CalleeValueIds, StaticCount> tuples when no PGO data exists, or <CalleeValueId, StaticCount, ProfileCount> pairs when there is PGO, where the ValueId can be mapped to the function GUID via the ValueSymbolTable. In the function index in memory, the call graph edges reference the target via the CalleeGUID instead of the CalleeValueId. The reference graph edges are recorded in each summary record with a list of referenced value IDs, which can be mapped to value GUID via the ValueSymbolTable. Addtionally, a new summary record type is added to record references from global variable initializers. A number of bitcode records and data structures have been renamed to reflect the newly expanded scope of the summary beyond functions. More cleanup will follow. Reviewers: joker.eph, davidxl Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D17212 llvm-svn: 263275
Diffstat (limited to 'llvm/test/Bitcode')
-rw-r--r--llvm/test/Bitcode/Inputs/thinlto-function-summary-callgraph-pgo.ll11
-rw-r--r--llvm/test/Bitcode/Inputs/thinlto-function-summary-callgraph.ll10
-rw-r--r--llvm/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll44
-rw-r--r--llvm/test/Bitcode/thinlto-function-summary-callgraph.ll42
-rw-r--r--llvm/test/Bitcode/thinlto-function-summary-refgraph.ll121
-rw-r--r--llvm/test/Bitcode/thinlto-function-summary.ll10
-rw-r--r--llvm/test/Bitcode/thinlto-summary-linkage-types.ll32
7 files changed, 249 insertions, 21 deletions
diff --git a/llvm/test/Bitcode/Inputs/thinlto-function-summary-callgraph-pgo.ll b/llvm/test/Bitcode/Inputs/thinlto-function-summary-callgraph-pgo.ll
new file mode 100644
index 00000000000..f51ea4d500b
--- /dev/null
+++ b/llvm/test/Bitcode/Inputs/thinlto-function-summary-callgraph-pgo.ll
@@ -0,0 +1,11 @@
+; ModuleID = 'thinlto-function-summary-callgraph2.ll'
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: nounwind uwtable
+define void @func() #0 !prof !2 {
+entry:
+ ret void
+}
+
+!2 = !{!"function_entry_count", i64 1}
diff --git a/llvm/test/Bitcode/Inputs/thinlto-function-summary-callgraph.ll b/llvm/test/Bitcode/Inputs/thinlto-function-summary-callgraph.ll
new file mode 100644
index 00000000000..c6ede3252d8
--- /dev/null
+++ b/llvm/test/Bitcode/Inputs/thinlto-function-summary-callgraph.ll
@@ -0,0 +1,10 @@
+; ModuleID = 'thinlto-function-summary-callgraph2.ll'
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: nounwind uwtable
+define void @func() #0 {
+entry:
+ ret void
+}
+
diff --git a/llvm/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll b/llvm/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll
new file mode 100644
index 00000000000..691239b7a40
--- /dev/null
+++ b/llvm/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll
@@ -0,0 +1,44 @@
+; Test to check the callgraph in summary when there is PGO
+; RUN: llvm-as -function-summary %s -o %t.o
+; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
+; RUN: llvm-as -function-summary %p/Inputs/thinlto-function-summary-callgraph.ll -o %t2.o
+; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
+; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
+
+; CHECK: <GLOBALVAL_SUMMARY_BLOCK
+; See if the call to func is registered, using the expected callsite count
+; and profile count, with value id matching the subsequent value symbol table.
+; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op4=[[FUNCID:[0-9]+]] op5=1 op6=1/>
+; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
+; CHECK-NEXT: <VALUE_SYMTAB
+; CHECK-NEXT: <FNENTRY {{.*}} record string = 'main'
+; External function func should have entry with value id FUNCID
+; CHECK-NEXT: <ENTRY {{.*}} op0=[[FUNCID]] {{.*}} record string = 'func'
+; CHECK-NEXT: </VALUE_SYMTAB>
+
+; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
+; COMBINED-NEXT: <COMBINED
+; See if the call to func is registered, using the expected callsite count
+; and profile count, with value id matching the subsequent value symbol table.
+; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op4=[[FUNCID:[0-9]+]] op5=1 op6=1/>
+; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
+; COMBINED-NEXT: <VALUE_SYMTAB
+; Entry for function func should have entry with value id FUNCID
+; COMBINED-NEXT: <COMBINED_GVDEFENTRY {{.*}} op0=[[FUNCID]] {{.*}} op2=7289175272376759421/>
+; COMBINED-NEXT: <COMBINED_GVDEFENTRY
+; COMBINED-NEXT: </VALUE_SYMTAB>
+
+; ModuleID = 'thinlto-function-summary-callgraph.ll'
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: nounwind uwtable
+define i32 @main() #0 !prof !2 {
+entry:
+ call void (...) @func()
+ ret i32 0
+}
+
+declare void @func(...) #1
+
+!2 = !{!"function_entry_count", i64 1}
diff --git a/llvm/test/Bitcode/thinlto-function-summary-callgraph.ll b/llvm/test/Bitcode/thinlto-function-summary-callgraph.ll
new file mode 100644
index 00000000000..a6a2685690f
--- /dev/null
+++ b/llvm/test/Bitcode/thinlto-function-summary-callgraph.ll
@@ -0,0 +1,42 @@
+; Test to check the callgraph in summary
+; RUN: llvm-as -function-summary %s -o %t.o
+; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
+; RUN: llvm-as -function-summary %p/Inputs/thinlto-function-summary-callgraph.ll -o %t2.o
+; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
+; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
+
+; CHECK: <GLOBALVAL_SUMMARY_BLOCK
+; See if the call to func is registered, using the expected callsite count
+; and value id matching the subsequent value symbol table.
+; CHECK-NEXT: <PERMODULE {{.*}} op4=[[FUNCID:[0-9]+]] op5=1/>
+; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
+; CHECK-NEXT: <VALUE_SYMTAB
+; CHECK-NEXT: <FNENTRY {{.*}} record string = 'main'
+; External function func should have entry with value id FUNCID
+; CHECK-NEXT: <ENTRY {{.*}} op0=[[FUNCID]] {{.*}} record string = 'func'
+; CHECK-NEXT: </VALUE_SYMTAB>
+
+; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
+; COMBINED-NEXT: <COMBINED
+; See if the call to func is registered, using the expected callsite count
+; and value id matching the subsequent value symbol table.
+; COMBINED-NEXT: <COMBINED {{.*}} op4=[[FUNCID:[0-9]+]] op5=1/>
+; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
+; COMBINED-NEXT: <VALUE_SYMTAB
+; Entry for function func should have entry with value id FUNCID
+; COMBINED-NEXT: <COMBINED_GVDEFENTRY {{.*}} op0=[[FUNCID]] {{.*}} op2=7289175272376759421/>
+; COMBINED-NEXT: <COMBINED_GVDEFENTRY
+; COMBINED-NEXT: </VALUE_SYMTAB>
+
+; ModuleID = 'thinlto-function-summary-callgraph.ll'
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: nounwind uwtable
+define i32 @main() #0 {
+entry:
+ call void (...) @func()
+ ret i32 0
+}
+
+declare void @func(...) #1
diff --git a/llvm/test/Bitcode/thinlto-function-summary-refgraph.ll b/llvm/test/Bitcode/thinlto-function-summary-refgraph.ll
new file mode 100644
index 00000000000..5f9fc3b5b0d
--- /dev/null
+++ b/llvm/test/Bitcode/thinlto-function-summary-refgraph.ll
@@ -0,0 +1,121 @@
+; Test to check both the callgraph and refgraph in summary
+; RUN: llvm-as -function-summary %s -o %t.o
+; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
+
+; See if the calls and other references are recorded properly using the
+; expected value id and other information as appropriate (callsite cout
+; for calls). Use different linkage types for the various test cases to
+; distinguish the test cases here (op1 contains the linkage type).
+; Note that op3 contains the # non-call references.
+; This also ensures that we didn't include a call or reference to intrinsic
+; llvm.ctpop.i8.
+; CHECK: <GLOBALVAL_SUMMARY_BLOCK
+; Function main contains call to func, as well as address reference to func:
+; CHECK-DAG: <PERMODULE {{.*}} op0=[[MAINID:[0-9]+]] op1=0 {{.*}} op3=1 op4=[[FUNCID:[0-9]+]] op5=[[FUNCID]] op6=1/>
+; Function W contains a call to func3 as well as a reference to globalvar:
+; CHECK-DAG: <PERMODULE {{.*}} op0=[[WID:[0-9]+]] op1=17 {{.*}} op3=1 op4=[[GLOBALVARID:[0-9]+]] op5=[[FUNC3ID:[0-9]+]] op6=1/>
+; Function X contains call to foo, as well as address reference to foo
+; which is in the same instruction as the call:
+; CHECK-DAG: <PERMODULE {{.*}} op0=[[XID:[0-9]+]] op1=12 {{.*}} op3=1 op4=[[FOOID:[0-9]+]] op5=[[FOOID]] op6=1/>
+; Function Y contains call to func2, and ensures we don't incorrectly add
+; a reference to it when reached while earlier analyzing the phi using its
+; return value:
+; CHECK-DAG: <PERMODULE {{.*}} op0=[[YID:[0-9]+]] op1=9 {{.*}} op3=0 op4=[[FUNC2ID:[0-9]+]] op5=1/>
+; Function Z contains call to func2, and ensures we don't incorrectly add
+; a reference to it when reached while analyzing subsequent use of its return
+; value:
+; CHECK-DAG: <PERMODULE {{.*}} op0=[[ZID:[0-9]+]] op1=19 {{.*}} op3=0 op4=[[FUNC2ID:[0-9]+]] op5=1/>
+; Variable bar initialization contains address reference to func:
+; CHECK-DAG: <PERMODULE_GLOBALVAR_INIT_REFS {{.*}} op0=[[BARID:[0-9]+]] op1=0 op2=[[FUNCID]]/>
+; CHECK: </GLOBALVAL_SUMMARY_BLOCK>
+
+; CHECK-NEXT: <VALUE_SYMTAB
+; CHECK-DAG: <ENTRY {{.*}} op0=[[BARID]] {{.*}} record string = 'bar'
+; CHECK-DAG: <ENTRY {{.*}} op0=[[FUNCID]] {{.*}} record string = 'func'
+; CHECK-DAG: <ENTRY {{.*}} op0=[[FOOID]] {{.*}} record string = 'foo'
+; CHECK-DAG: <FNENTRY {{.*}} op0=[[MAINID]] {{.*}} record string = 'main'
+; CHECK-DAG: <FNENTRY {{.*}} op0=[[WID]] {{.*}} record string = 'W'
+; CHECK-DAG: <FNENTRY {{.*}} op0=[[XID]] {{.*}} record string = 'X'
+; CHECK-DAG: <FNENTRY {{.*}} op0=[[YID]] {{.*}} record string = 'Y'
+; CHECK-DAG: <FNENTRY {{.*}} op0=[[ZID]] {{.*}} record string = 'Z'
+; CHECK-DAG: <ENTRY {{.*}} op0=[[FUNC2ID]] {{.*}} record string = 'func2'
+; CHECK-DAG: <ENTRY {{.*}} op0=[[FUNC3ID]] {{.*}} record string = 'func3'
+; CHECK-DAG: <ENTRY {{.*}} op0=[[GLOBALVARID]] {{.*}} record string = 'globalvar'
+; CHECK: </VALUE_SYMTAB>
+
+; ModuleID = 'thinlto-function-summary-refgraph.ll'
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@bar = global void (...)* bitcast (void ()* @func to void (...)*), align 8
+
+@globalvar = global i32 0, align 4
+
+declare void @func() #0
+declare i32 @func2(...) #1
+declare void @foo(i8* %F) #0
+declare i32 @func3(i32* dereferenceable(4)) #2
+
+; Function Attrs: nounwind uwtable
+define weak_odr void @W() #0 {
+entry:
+ %call = tail call i32 @func3(i32* nonnull dereferenceable(4) @globalvar)
+ ret void
+}
+
+; Function Attrs: nounwind uwtable
+define available_externally void @X() #0 {
+entry:
+ call void @foo(i8* bitcast (void (i8*)* @foo to i8*))
+ ret void
+}
+
+; Function Attrs: nounwind uwtable
+define private i32 @Y(i32 %i) #0 {
+entry:
+ %cmp3 = icmp slt i32 %i, 10
+ br i1 %cmp3, label %while.body.preheader, label %while.end
+
+while.body.preheader: ; preds = %entry
+ br label %while.body
+
+while.body: ; preds = %while.body.preheader, %while.body
+ %j.05 = phi i32 [ %add, %while.body ], [ 0, %while.body.preheader ]
+ %i.addr.04 = phi i32 [ %inc, %while.body ], [ %i, %while.body.preheader ]
+ %inc = add nsw i32 %i.addr.04, 1
+ %call = tail call i32 (...) @func2() #2
+ %add = add nsw i32 %call, %j.05
+ %exitcond = icmp eq i32 %inc, 10
+ br i1 %exitcond, label %while.end.loopexit, label %while.body
+
+while.end.loopexit: ; preds = %while.body
+ %add.lcssa = phi i32 [ %add, %while.body ]
+ br label %while.end
+
+while.end: ; preds = %while.end.loopexit, %entry
+ %j.0.lcssa = phi i32 [ 0, %entry ], [ %add.lcssa, %while.end.loopexit ]
+ ret i32 %j.0.lcssa
+}
+
+; Function Attrs: nounwind uwtable
+define linkonce_odr i32 @Z() #0 {
+entry:
+ %call = tail call i32 (...) @func2() #2
+ ret i32 %call
+}
+
+declare i8 @llvm.ctpop.i8(i8)
+
+; Function Attrs: nounwind uwtable
+define i32 @main() #0 {
+entry:
+ %retval = alloca i32, align 4
+ %foo = alloca void (...)*, align 8
+ store i32 0, i32* %retval, align 4
+ store void (...)* bitcast (void ()* @func to void (...)*), void (...)** %foo, align 8
+ %0 = load void (...)*, void (...)** %foo, align 8
+ call void (...) %0()
+ call void @func()
+ call i8 @llvm.ctpop.i8( i8 10 )
+ ret i32 0
+}
diff --git a/llvm/test/Bitcode/thinlto-function-summary.ll b/llvm/test/Bitcode/thinlto-function-summary.ll
index e8d9b00d3eb..5f08e55124f 100644
--- a/llvm/test/Bitcode/thinlto-function-summary.ll
+++ b/llvm/test/Bitcode/thinlto-function-summary.ll
@@ -4,11 +4,11 @@
; Check the value ids in the function summary entries against the
; same in the ValueSumbolTable, to ensure the ordering is stable.
; Also check the linkage field on the summary entries.
-; BC: <FUNCTION_SUMMARY_BLOCK
-; BC-NEXT: <PERMODULE_ENTRY {{.*}} op0=1 op1=0
-; BC-NEXT: <PERMODULE_ENTRY {{.*}} op0=2 op1=0
-; BC-NEXT: <PERMODULE_ENTRY {{.*}} op0=4 op1=3
-; BC-NEXT: </FUNCTION_SUMMARY_BLOCK
+; BC: <GLOBALVAL_SUMMARY_BLOCK
+; BC-NEXT: <PERMODULE {{.*}} op0=1 op1=0
+; BC-NEXT: <PERMODULE {{.*}} op0=2 op1=0
+; BC-NEXT: <PERMODULE {{.*}} op0=4 op1=3
+; BC-NEXT: </GLOBALVAL_SUMMARY_BLOCK
; BC-NEXT: <VALUE_SYMTAB
; BC-NEXT: <FNENTRY {{.*}} op0=1 {{.*}}> record string = 'foo'
; BC-NEXT: <FNENTRY {{.*}} op0=2 {{.*}}> record string = 'bar'
diff --git a/llvm/test/Bitcode/thinlto-summary-linkage-types.ll b/llvm/test/Bitcode/thinlto-summary-linkage-types.ll
index 5b7391e238f..5983dd20474 100644
--- a/llvm/test/Bitcode/thinlto-summary-linkage-types.ll
+++ b/llvm/test/Bitcode/thinlto-summary-linkage-types.ll
@@ -5,57 +5,57 @@
; RUN: llvm-bcanalyzer -dump %t2.thinlto.bc | FileCheck %s --check-prefix=COMBINED
define private void @private()
-; CHECK: <PERMODULE_ENTRY {{.*}} op1=9
-; COMBINED-DAG: <COMBINED_ENTRY {{.*}} op1=9
+; CHECK: <PERMODULE {{.*}} op1=9
+; COMBINED-DAG: <COMBINED {{.*}} op1=9
{
ret void
}
define internal void @internal()
-; CHECK: <PERMODULE_ENTRY {{.*}} op1=3
-; COMBINED-DAG: <COMBINED_ENTRY {{.*}} op1=3
+; CHECK: <PERMODULE {{.*}} op1=3
+; COMBINED-DAG: <COMBINED {{.*}} op1=3
{
ret void
}
define available_externally void @available_externally()
-; CHECK: <PERMODULE_ENTRY {{.*}} op1=12
-; COMBINED-DAG: <COMBINED_ENTRY {{.*}} op1=12
+; CHECK: <PERMODULE {{.*}} op1=12
+; COMBINED-DAG: <COMBINED {{.*}} op1=12
{
ret void
}
define linkonce void @linkonce()
-; CHECK: <PERMODULE_ENTRY {{.*}} op1=18
-; COMBINED-DAG: <COMBINED_ENTRY {{.*}} op1=18
+; CHECK: <PERMODULE {{.*}} op1=18
+; COMBINED-DAG: <COMBINED {{.*}} op1=18
{
ret void
}
define weak void @weak()
-; CHECK: <PERMODULE_ENTRY {{.*}} op1=16
-; COMBINED-DAG: <COMBINED_ENTRY {{.*}} op1=16
+; CHECK: <PERMODULE {{.*}} op1=16
+; COMBINED-DAG: <COMBINED {{.*}} op1=16
{
ret void
}
define linkonce_odr void @linkonce_odr()
-; CHECK: <PERMODULE_ENTRY {{.*}} op1=19
-; COMBINED-DAG: <COMBINED_ENTRY {{.*}} op1=19
+; CHECK: <PERMODULE {{.*}} op1=19
+; COMBINED-DAG: <COMBINED {{.*}} op1=19
{
ret void
}
define weak_odr void @weak_odr()
-; CHECK: <PERMODULE_ENTRY {{.*}} op1=17
-; COMBINED-DAG: <COMBINED_ENTRY {{.*}} op1=17
+; CHECK: <PERMODULE {{.*}} op1=17
+; COMBINED-DAG: <COMBINED {{.*}} op1=17
{
ret void
}
define external void @external()
-; CHECK: <PERMODULE_ENTRY {{.*}} op1=0
-; COMBINED-DAG: <COMBINED_ENTRY {{.*}} op1=0
+; CHECK: <PERMODULE {{.*}} op1=0
+; COMBINED-DAG: <COMBINED {{.*}} op1=0
{
ret void
}
OpenPOWER on IntegriCloud