1; Test to check the callgraph in summary when there is PGO
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-pgo.1.bc  | FileCheck %s --check-prefix=OLD
11; RUN: llvm-lto -thinlto-index-stats %p/Inputs/thinlto-function-summary-callgraph-pgo-combined.1.bc  | FileCheck %s --check-prefix=OLD-COMBINED
12
13; CHECK:       <GLOBALVAL_SUMMARY_BLOCK
14; CHECK-NEXT:    <VERSION
15; See if the call to func is registered, using the expected callsite count
16; and hotness type, with value id matching the subsequent value symbol table.
17; CHECK-NEXT:    <PERMODULE_PROFILE {{.*}} op4=[[FUNCID:[0-9]+]] op5=2/>
18; CHECK-NEXT:  </GLOBALVAL_SUMMARY_BLOCK>
19; CHECK-NEXT:  <VALUE_SYMTAB
20; CHECK-NEXT:    <FNENTRY {{.*}} record string = 'main'
21; External function func should have entry with value id FUNCID
22; CHECK-NEXT:    <ENTRY {{.*}} op0=[[FUNCID]] {{.*}} record string = 'func'
23; CHECK-NEXT:  </VALUE_SYMTAB>
24
25; COMBINED:       <GLOBALVAL_SUMMARY_BLOCK
26; COMBINED-NEXT:    <VERSION
27; COMBINED-NEXT:    <COMBINED
28; See if the call to func is registered, using the expected callsite count
29; and hotness type, with value id matching the subsequent value symbol table.
30; op6=2 which is hotnessType::None.
31; COMBINED-NEXT:    <COMBINED_PROFILE {{.*}} op5=[[FUNCID:[0-9]+]] op6=2/>
32; COMBINED-NEXT:  </GLOBALVAL_SUMMARY_BLOCK>
33; COMBINED-NEXT:  <VALUE_SYMTAB
34; Entry for function func should have entry with value id FUNCID
35; COMBINED-NEXT:    <COMBINED_ENTRY {{.*}} op0=[[FUNCID]] op1=7289175272376759421/>
36; COMBINED-NEXT:    <COMBINED
37; COMBINED-NEXT:  </VALUE_SYMTAB>
38
39; ModuleID = 'thinlto-function-summary-callgraph.ll'
40target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
41target triple = "x86_64-unknown-linux-gnu"
42
43; Function Attrs: nounwind uwtable
44define i32 @main() #0 !prof !2 {
45entry:
46    call void (...) @func()
47    ret i32 0
48}
49
50declare void @func(...) #1
51
52!2 = !{!"function_entry_count", i64 1}
53
54; OLD: Index {{.*}} contains 1 nodes (1 functions, 0 alias, 0 globals) and 1 edges (0 refs and 1 calls)
55; OLD-COMBINED: Index {{.*}} contains 2 nodes (2 functions, 0 alias, 0 globals) and 1 edges (0 refs and 1 calls)
56