1; Test to check the callgraph in summary
2; RUN: opt -module-summary %s -o %t.o
3; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
4
5; RUN: opt -module-summary %p/Inputs/thinlto-function-summary-callgraph.ll -o %t2.o
6; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
7; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
8
9; Check parsing for old summary versions generated from this file.
10; RUN: llvm-lto -thinlto-index-stats %p/Inputs/thinlto-function-summary-callgraph.1.bc  | FileCheck %s --check-prefix=OLD
11; RUN: llvm-lto -thinlto-index-stats %p/Inputs/thinlto-function-summary-callgraph-combined.1.bc  | FileCheck %s --check-prefix=OLD-COMBINED
12
13; CHECK: <SOURCE_FILENAME
14; CHECK-NEXT: <GLOBALVAR
15; CHECK-NEXT: <FUNCTION
16; "func"
17; CHECK-NEXT: <FUNCTION op0=17 op1=4
18; CHECK:       <GLOBALVAL_SUMMARY_BLOCK
19; CHECK-NEXT:    <VERSION
20; CHECK-NEXT:    <FLAGS
21; See if the call to func is registered
22; CHECK-NEXT:    <PERMODULE {{.*}} op4=1
23; CHECK-NEXT:    <BLOCK_COUNT op0=1/>
24; CHECK-NEXT:  </GLOBALVAL_SUMMARY_BLOCK>
25; CHECK: <STRTAB_BLOCK
26; CHECK-NEXT: blob data = 'undefinedglobmainfunc{{.*}}'
27
28
29; COMBINED:       <GLOBALVAL_SUMMARY_BLOCK
30; COMBINED-NEXT:    <VERSION
31; COMBINED-NEXT:    <FLAGS
32; Only 2 VALUE_GUID since reference to undefinedglob should not be included in
33; combined index.
34; COMBINED-NEXT:    <VALUE_GUID op0=[[FUNCID:[0-9]+]] op1=7289175272376759421/>
35; COMBINED-NEXT:    <VALUE_GUID
36; COMBINED-NEXT:    <COMBINED
37; See if the call to func is registered.
38; COMBINED-NEXT:    <COMBINED {{.*}} op9=[[FUNCID]]/>
39; COMBINED-NEXT:    <BLOCK_COUNT op0=2/>
40; COMBINED-NEXT:  </GLOBALVAL_SUMMARY_BLOCK>
41
42; ModuleID = 'thinlto-function-summary-callgraph.ll'
43target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
44target triple = "x86_64-unknown-linux-gnu"
45
46; Function Attrs: nounwind uwtable
47define i32 @main() #0 {
48entry:
49    call void (...) @func()
50    %u = load i32, i32* @undefinedglob
51    ret i32 %u
52}
53
54declare void @func(...) #1
55@undefinedglob = external global i32
56
57; OLD: Index {{.*}} contains 1 nodes (1 functions, 0 alias, 0 globals) and 1 edges (0 refs and 1 calls)
58; OLD-COMBINED: Index {{.*}} contains 2 nodes (2 functions, 0 alias, 0 globals) and 1 edges (0 refs and 1 calls)
59