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