1; RUN: opt -name-anon-globals -module-summary < %s | llvm-bcanalyzer -dump | FileCheck %s -check-prefix=BC
2; RUN: opt -passes=name-anon-globals -module-summary < %s | llvm-bcanalyzer -dump | FileCheck %s -check-prefix=BC
3; Check for summary block/records.
4
5; Check the value ids in the summary entries against the
6; same in the ValueSumbolTable, to ensure the ordering is stable.
7; Also check the linkage field on the summary entries.
8; BC: <GLOBALVAL_SUMMARY_BLOCK
9; BC-NEXT: <VERSION
10; BC-NEXT: <PERMODULE {{.*}} op0=1 op1=0
11; BC-NEXT: <PERMODULE {{.*}} op0=2 op1=0
12; BC-NEXT: <PERMODULE {{.*}} op0=3 op1=7
13; BC-NEXT: <PERMODULE {{.*}} op0=4 op1=32
14; BC-NEXT: <ALIAS {{.*}} op0=5 op1=0 op2=3
15; BC-NEXT: </GLOBALVAL_SUMMARY_BLOCK
16; BC-NEXT: <VALUE_SYMTAB
17; BC-NEXT: <FNENTRY {{.*}} op0=4 {{.*}}> record string = 'variadic'
18; BC-NEXT: <FNENTRY {{.*}} op0=1 {{.*}}> record string = 'foo'
19; BC-NEXT: <FNENTRY {{.*}} op0=2 {{.*}}> record string = 'bar'
20; BC-NEXT: <FNENTRY {{.*}} op0=5 {{.*}}> record string = 'f'
21; BC-NEXT: <ENTRY {{.*}} record string = 'h'
22; BC-NEXT: <FNENTRY {{.*}} op0=3 {{.*}}> record string = 'anon.
23
24
25; RUN: opt -name-anon-globals -module-summary < %s | llvm-dis | FileCheck %s
26; Check that this round-trips correctly.
27
28; ModuleID = '<stdin>'
29target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
30target triple = "x86_64-unknown-linux-gnu"
31
32; CHECK: define i32 @foo()
33
34; Function Attrs: nounwind uwtable
35define i32 @foo() #0 {
36entry:
37  ret i32 1
38}
39
40; CHECK: define i32 @bar(i32 %x)
41
42; Function Attrs: nounwind uwtable
43define i32 @bar(i32 %x) #0 {
44entry:
45  ret i32 %x
46}
47
48; FIXME: Anonymous function and alias not currently in summary until
49; follow on fixes to rename anonymous globals and emit alias summary
50; entries are committed.
51; Check an anonymous function as well, since in that case only the alias
52; ends up in the value symbol table and having a summary.
53@f = alias void (), void ()* @0   ; <void ()*> [#uses=0]
54@h = external global void ()*     ; <void ()*> [#uses=0]
55
56define internal void @0() nounwind {
57entry:
58  store void()* @0, void()** @h
59        br label %return
60
61return:         ; preds = %entry
62        ret void
63}
64
65define i32 @variadic(...) {
66    ret i32 42
67}
68