176a1c1d0STeresa Johnson; Test to check the callgraph in summary
268da426eSMehdi Amini; RUN: opt -module-summary %s -o %t.o
376a1c1d0STeresa Johnson; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
4d9830eb7SPiotr Padlewski
568da426eSMehdi Amini; RUN: opt -module-summary %p/Inputs/thinlto-function-summary-callgraph.ll -o %t2.o
676a1c1d0STeresa Johnson; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
776a1c1d0STeresa Johnson; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
876a1c1d0STeresa Johnson
9d9830eb7SPiotr Padlewski; Check parsing for old summary versions generated from this file.
10d9830eb7SPiotr Padlewski; RUN: llvm-lto -thinlto-index-stats %p/Inputs/thinlto-function-summary-callgraph.1.bc  | FileCheck %s --check-prefix=OLD
11d9830eb7SPiotr Padlewski; RUN: llvm-lto -thinlto-index-stats %p/Inputs/thinlto-function-summary-callgraph-combined.1.bc  | FileCheck %s --check-prefix=OLD-COMBINED
12d9830eb7SPiotr Padlewski
13a0f371a1SPeter Collingbourne; CHECK: <SOURCE_FILENAME
14a6a3fb57STeresa Johnson; CHECK-NEXT: <GLOBALVAR
15a0f371a1SPeter Collingbourne; CHECK-NEXT: <FUNCTION
16a0f371a1SPeter Collingbourne; "func"
17a6a3fb57STeresa Johnson; CHECK-NEXT: <FUNCTION op0=17 op1=4
1876a1c1d0STeresa Johnson; CHECK:       <GLOBALVAL_SUMMARY_BLOCK
198fe6936eSMehdi Amini; CHECK-NEXT:    <VERSION
20290a8398STeresa Johnson; CHECK-NEXT:    <FLAGS
21bf46e741SEugene Leviant; See if the call to func is registered
2275da10d1SCharles Saternos; CHECK-NEXT:    <PERMODULE {{.*}} op4=1
23*a7fa35a6SHiroshi Yamauchi; CHECK-NEXT:    <BLOCK_COUNT op0=1/>
2476a1c1d0STeresa Johnson; CHECK-NEXT:  </GLOBALVAL_SUMMARY_BLOCK>
25a0f371a1SPeter Collingbourne; CHECK: <STRTAB_BLOCK
2692648c25SPeter Collingbourne; CHECK-NEXT: blob data = 'undefinedglobmainfunc{{.*}}'
27a0f371a1SPeter Collingbourne
2876a1c1d0STeresa Johnson
2976a1c1d0STeresa Johnson; COMBINED:       <GLOBALVAL_SUMMARY_BLOCK
308fe6936eSMehdi Amini; COMBINED-NEXT:    <VERSION
31f3681015STeresa Johnson; COMBINED-NEXT:    <FLAGS
32a6a3fb57STeresa Johnson; Only 2 VALUE_GUID since reference to undefinedglob should not be included in
33a6a3fb57STeresa Johnson; combined index.
34a0f371a1SPeter Collingbourne; COMBINED-NEXT:    <VALUE_GUID op0=[[FUNCID:[0-9]+]] op1=7289175272376759421/>
35a0f371a1SPeter Collingbourne; COMBINED-NEXT:    <VALUE_GUID
3676a1c1d0STeresa Johnson; COMBINED-NEXT:    <COMBINED
37a0f371a1SPeter Collingbourne; See if the call to func is registered.
383aef3528SEugene Leviant; COMBINED-NEXT:    <COMBINED {{.*}} op9=[[FUNCID]]/>
39*a7fa35a6SHiroshi Yamauchi; COMBINED-NEXT:    <BLOCK_COUNT op0=2/>
4076a1c1d0STeresa Johnson; COMBINED-NEXT:  </GLOBALVAL_SUMMARY_BLOCK>
4176a1c1d0STeresa Johnson
4276a1c1d0STeresa Johnson; ModuleID = 'thinlto-function-summary-callgraph.ll'
4376a1c1d0STeresa Johnsontarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4476a1c1d0STeresa Johnsontarget triple = "x86_64-unknown-linux-gnu"
4576a1c1d0STeresa Johnson
4676a1c1d0STeresa Johnson; Function Attrs: nounwind uwtable
4776a1c1d0STeresa Johnsondefine i32 @main() #0 {
4876a1c1d0STeresa Johnsonentry:
4976a1c1d0STeresa Johnson    call void (...) @func()
50a6a3fb57STeresa Johnson    %u = load i32, i32* @undefinedglob
51a6a3fb57STeresa Johnson    ret i32 %u
5276a1c1d0STeresa Johnson}
5376a1c1d0STeresa Johnson
5476a1c1d0STeresa Johnsondeclare void @func(...) #1
55a6a3fb57STeresa Johnson@undefinedglob = external global i32
56d9830eb7SPiotr Padlewski
57d9830eb7SPiotr Padlewski; OLD: Index {{.*}} contains 1 nodes (1 functions, 0 alias, 0 globals) and 1 edges (0 refs and 1 calls)
58d9830eb7SPiotr Padlewski; OLD-COMBINED: Index {{.*}} contains 2 nodes (2 functions, 0 alias, 0 globals) and 1 edges (0 refs and 1 calls)
59