blob: 5922a8b3c4d0b1f00d7632c9db2b9c9ab2cd8a63 [file] [log] [blame]
Mehdi Amini55b06532016-09-16 17:18:16 +00001; 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
Teresa Johnson26ab5772016-03-15 00:04:37 +00003; Check for summary block/records.
Teresa Johnson403a7872015-10-04 14:33:43 +00004
Peter Collingbournea0f371a2017-04-17 17:51:36 +00005; 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
Teresa Johnson76a1c1d2016-03-11 18:52:24 +000018; BC: <GLOBALVAL_SUMMARY_BLOCK
Mehdi Amini8fe69362016-04-24 03:18:11 +000019; BC-NEXT: <VERSION
Teresa Johnson76a1c1d2016-03-11 18:52:24 +000020; BC-NEXT: <PERMODULE {{.*}} op0=1 op1=0
21; BC-NEXT: <PERMODULE {{.*}} op0=2 op1=0
Mehdi Aminic3ed48c2016-04-24 03:18:18 +000022; BC-NEXT: <PERMODULE {{.*}} op0=3 op1=7
Teresa Johnson519465b2017-01-05 14:32:16 +000023; BC-NEXT: <PERMODULE {{.*}} op0=4 op1=16
Piotr Padlewski332b3b22016-08-11 22:13:57 +000024; BC-NEXT: <ALIAS {{.*}} op0=5 op1=0 op2=3
Mehdi Aminib5b28932016-04-13 17:20:07 +000025; BC-NEXT: </GLOBALVAL_SUMMARY_BLOCK
Peter Collingbournea0f371a2017-04-17 17:51:36 +000026; BC: <STRTAB_BLOCK
Peter Collingbourne92648c22017-06-27 23:50:11 +000027; BC-NEXT: blob data = 'hfoobaranon.{{................................}}.0variadicf{{.*}}'
Piotr Padlewski332b3b22016-08-11 22:13:57 +000028
Teresa Johnson403a7872015-10-04 14:33:43 +000029
Mehdi Amini55b06532016-09-16 17:18:16 +000030; RUN: opt -name-anon-globals -module-summary < %s | llvm-dis | FileCheck %s
Teresa Johnson403a7872015-10-04 14:33:43 +000031; 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
Teresa Johnson2d5487c2016-04-11 13:58:45 +000053; FIXME: Anonymous function and alias not currently in summary until
Mehdi Amini55b06532016-09-16 17:18:16 +000054; follow on fixes to rename anonymous globals and emit alias summary
Teresa Johnson2d5487c2016-04-11 13:58:45 +000055; entries are committed.
Teresa Johnson403a7872015-10-04 14:33:43 +000056; 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}
Piotr Padlewski332b3b22016-08-11 22:13:57 +000069
70define i32 @variadic(...) {
71 ret i32 42
72}