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; BC: <SOURCE_FILENAME
6; "h"
7; BC-NEXT: <GLOBALVAR {{.*}} op0=0 op1=1
8; "foo"
9; BC-NEXT: <FUNCTION op0=1 op1=3
10; "bar"
11; BC-NEXT: <FUNCTION op0=4 op1=3
12; "anon.[32 chars].0"
13; BC-NEXT: <FUNCTION op0=7 op1=39
14; "variadic"
15; BC-NEXT: <FUNCTION op0=46 op1=8
16; "llvm.va_start"
17; BC-NEXT: <FUNCTION op0=54 op1=13
18; "f"
19; BC-NEXT: <ALIAS op0=67 op1=1
20; BC: <GLOBALVAL_SUMMARY_BLOCK
21; BC-NEXT: <VERSION
22; BC-NEXT: <PERMODULE {{.*}} op0=1 op1=0
23; BC-NEXT: <PERMODULE {{.*}} op0=2 op1=0
24; BC-NEXT: <PERMODULE {{.*}} op0=3 op1=7
25; Summary for @variadic has flags (op3) = 16 since non-inlinable owing to
26; va_start call.
27; flag is set due to va_start call.
28; BC-NEXT: <PERMODULE {{.*}} op0=4 op1=0 op2=4 op3=16
29; BC-NEXT: <ALIAS {{.*}} op0=6 op1=0 op2=3
30; BC-NEXT: </GLOBALVAL_SUMMARY_BLOCK
31; BC: <STRTAB_BLOCK
32; BC-NEXT: blob data = 'hfoobaranon.{{................................}}.0variadicllvm.va_startf{{.*}}'
33
34
35; RUN: opt -name-anon-globals -module-summary < %s | llvm-dis | FileCheck %s
36; Check that this round-trips correctly.
37
38; ModuleID = '<stdin>'
39target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
40target triple = "x86_64-unknown-linux-gnu"
41
42; CHECK: define i32 @foo()
43
44; Function Attrs: nounwind uwtable
45define i32 @foo() #0 {
46entry:
47  ret i32 1
48}
49
50; CHECK: define i32 @bar(i32 %x)
51
52; Function Attrs: nounwind uwtable
53define i32 @bar(i32 %x) #0 {
54entry:
55  ret i32 %x
56}
57
58; FIXME: Anonymous function and alias not currently in summary until
59; follow on fixes to rename anonymous globals and emit alias summary
60; entries are committed.
61; Check an anonymous function as well, since in that case only the alias
62; ends up in the value symbol table and having a summary.
63@f = alias void (), void ()* @0   ; <void ()*> [#uses=0]
64@h = external global void ()*     ; <void ()*> [#uses=0]
65
66define internal void @0() nounwind {
67entry:
68  store void()* @0, void()** @h
69        br label %return
70
71return:         ; preds = %entry
72        ret void
73}
74
75define i32 @variadic(...) {
76    %ap = alloca i8*, align 8
77    %ap.0 = bitcast i8** %ap to i8*
78    call void @llvm.va_start(i8* %ap.0)
79    ret i32 42
80}
81
82declare void @llvm.va_start(i8*) nounwind
83