llvm.org GIT mirror llvm / 7ff3d07
IR: print value numbers for unnamed function arguments For consistency with normal instructions and clarity when reading IR, it's best to print the %0, %1, ... names of function arguments in definitions. Also modifies the parser to accept IR in that form for obvious reasons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367755 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover a month ago
49 changed file(s) with 474 addition(s) and 338 deletion(s). Raw diff Collapse all Expand all
5151
5252 Changes to the LLVM IR
5353 ----------------------
54
55 * Unnamed function arguments now get printed with their automatically
56 generated name (e.g. "i32 %0") in definitions. This may require front-ends
57 to update their tests; if so there is a script utils/add_argument_names.py
58 that correctly converted 80-90% of Clang tests. Some manual work will almost
59 certainly still be needed.
60
5461
5562 Changes to building LLVM
5663 ------------------------
25502550 ///
25512551 bool LLParser::ParseArgumentList(SmallVectorImpl &ArgList,
25522552 bool &isVarArg){
2553 unsigned CurValID = 0;
25532554 isVarArg = false;
25542555 assert(Lex.getKind() == lltok::lparen);
25552556 Lex.Lex(); // eat the (.
25742575 if (Lex.getKind() == lltok::LocalVar) {
25752576 Name = Lex.getStrVal();
25762577 Lex.Lex();
2578 } else if (Lex.getKind() == lltok::LocalVarID) {
2579 if (Lex.getUIntVal() != CurValID)
2580 return Error(TypeLoc, "argument expected to be numbered '%" +
2581 Twine(CurValID) + "'");
2582 ++CurValID;
2583 Lex.Lex();
25772584 }
25782585
25792586 if (!FunctionType::isValidArgumentType(ArgTy))
26012608 Name = Lex.getStrVal();
26022609 Lex.Lex();
26032610 } else {
2611 if (Lex.getKind() == lltok::LocalVarID) {
2612 if (Lex.getUIntVal() != CurValID)
2613 return Error(TypeLoc, "argument expected to be numbered '%" +
2614 Twine(CurValID) + "'");
2615 Lex.Lex();
2616 }
2617 ++CurValID;
26042618 Name = "";
26052619 }
26062620
35523552 if (Arg->hasName()) {
35533553 Out << ' ';
35543554 PrintLLVMName(Out, Arg);
3555 } else {
3556 int Slot = Machine.getLocalSlot(Arg);
3557 assert(Slot != -1 && "expect argument in function here");
3558 Out << " %" << Slot;
35553559 }
35563560 }
35573561
3737 ; CHECK-NEXT: ret i32 %4
3838 ; CHECK-NEXT: }
3939
40 define void @test2(i32, i32) {
40 define void @test2(i32 %0, i32 %1) {
4141 ; entry label id still not printed on output
4242 2:
4343 ret void
4444 }
4545
46 ; CHECK-LABEL: define void @test2(i32, i32) {
46 ; CHECK-LABEL: define void @test2(i32 %0, i32 %1) {
4747 ; CHECK-NEXT: ret void
0 ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
11
2 ; CHECK: define void @foo(i32* byval(i32) align 4)
3 define void @foo(i32* byval(i32) align 4) {
2 ; CHECK: define void @foo(i32* byval(i32) align 4 %0)
3 define void @foo(i32* byval(i32) align 4 %0) {
44 ret void
55 }
66
7 ; CHECK: define void @bar({ i32*, i8 }* byval({ i32*, i8 }) align 4)
8 define void @bar({i32*, i8}* byval({i32*, i8}) align 4) {
7 ; CHECK: define void @bar({ i32*, i8 }* byval({ i32*, i8 }) align 4 %0)
8 define void @bar({i32*, i8}* byval({i32*, i8}) align 4 %0) {
99 ret void
1010 }
1111
22
33 ; Check that numbered variables in a nonzero program address space 200 can be used in a call instruction
44
5 define i8 @test_unnamed(i8(i32)*, i8(i32) addrspace(42)*) {
5 define i8 @test_unnamed(i8(i32)*, i8(i32) addrspace(42)* %0) {
66 ; Calls with explicit address spaces are fine:
77 call addrspace(0) i8 %0(i32 0)
88 call addrspace(42) i8 %1(i32 0)
1313 }
1414
1515 ; PROGAS42: target datalayout = "P42"
16 ; PROGAS42: define i8 @test_unnamed(i8 (i32)*, i8 (i32) addrspace(42)*) addrspace(42) {
16 ; PROGAS42: define i8 @test_unnamed(i8 (i32)* %0, i8 (i32) addrspace(42)* %1) addrspace(42) {
1717 ; PROGAS42-NEXT: %3 = call addrspace(0) i8 %0(i32 0)
1818 ; PROGAS42-NEXT: %4 = call addrspace(42) i8 %1(i32 0)
1919 ; PROGAS42-NEXT: %5 = call addrspace(42) i8 %1(i32 0)
0 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
11
2 ; CHECK: define i32 @f(i64 "foo bar", i64, i64, i64 "xyz") {
2 ; CHECK: define i32 @f(i64 "foo bar" %0, i64 %1, i64 %2, i64 "xyz" %3) {
33 define i32 @f(i64 "foo bar", i64, i64, i64 "xyz") {
44 ret i32 41
55 }
0 ; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
1
2 ; CHECK: error: argument expected to be numbered '%1'
3 define void @foo(i32 %0, i32 %5) {
4 ret void
5 }
0 ; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
1
2 ; CHECK: error: argument expected to be numbered '%1'
3 define void @foo(i8 %0, i32 %named, i32 %2) {
4 ret void
5 }
0 ; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
1
2 ; CHECK: error: argument expected to be numbered '%0'
3 define void @foo(i8 %1) {
4 ret void
5 }
22 ; CHECK: ; ModuleID = 'debuginfo.c'
33 ; CHECK-NEXT: source_filename = "debuginfo.c"
44
5 ; CHECK: define i64 @foo(i64, i64, <10 x i64>) !dbg !20 {
5 ; CHECK: define i64 @foo(i64 %0, i64 %1, <10 x i64> %2) !dbg !20 {
66 ; CHECK-NEXT: entry:
77 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !27, metadata !DIExpression()), !dbg !32
88 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !28, metadata !DIExpression()), !dbg !32
44 ; The test checks that LLVM does not silently misread attributes of
55 ; older bitcode files.
66
7 define void @f1(i8 zeroext)
8 ; CHECK: define void @f1(i8 zeroext)
9 {
10 ret void;
11 }
12
13 define void @f2(i8 signext)
14 ; CHECK: define void @f2(i8 signext)
7 define void @f1(i8 zeroext %0)
8 ; CHECK: define void @f1(i8 zeroext %0)
9 {
10 ret void;
11 }
12
13 define void @f2(i8 signext %0)
14 ; CHECK: define void @f2(i8 signext %0)
1515 {
1616 ret void;
1717 }
2222 ret void;
2323 }
2424
25 define void @f4(i8 inreg)
26 ; CHECK: define void @f4(i8 inreg)
27 {
28 ret void;
29 }
30
31 define void @f5(i8* sret)
32 ; CHECK: define void @f5(i8* sret)
25 define void @f4(i8 inreg %0)
26 ; CHECK: define void @f4(i8 inreg %0)
27 {
28 ret void;
29 }
30
31 define void @f5(i8* sret %0)
32 ; CHECK: define void @f5(i8* sret %0)
3333 {
3434 ret void;
3535 }
4040 ret void;
4141 }
4242
43 define void @f7(i8* noalias)
44 ; CHECK: define void @f7(i8* noalias)
45 {
46 ret void;
47 }
48
49 define void @f8(i8* byval)
50 ; CHECK: define void @f8(i8* byval(i8))
51 {
52 ret void;
53 }
54
55 define void @f9(i8* nest)
56 ; CHECK: define void @f9(i8* nest)
43 define void @f7(i8* noalias %0)
44 ; CHECK: define void @f7(i8* noalias %0)
45 {
46 ret void;
47 }
48
49 define void @f8(i8* byval %0)
50 ; CHECK: define void @f8(i8* byval(i8) %0)
51 {
52 ret void;
53 }
54
55 define void @f9(i8* nest %0)
56 ; CHECK: define void @f9(i8* nest %0)
5757 {
5858 ret void;
5959 }
100100 ret void;
101101 }
102102
103 define void @f17(i8 align 4)
104 ; CHECK: define void @f17(i8 align 4)
105 {
106 ret void;
107 }
108
109 define void @f18(i8* nocapture)
110 ; CHECK: define void @f18(i8* nocapture)
103 define void @f17(i8 align 4 %0)
104 ; CHECK: define void @f17(i8 align 4 %0)
105 {
106 ret void;
107 }
108
109 define void @f18(i8* nocapture %0)
110 ; CHECK: define void @f18(i8* nocapture %0)
111111 {
112112 ret void;
113113 }
11 ; RUN: verify-uselistorder < %s
22 ; PR12696
33
4 define void @f1(i8 zeroext)
5 ; CHECK: define void @f1(i8 zeroext)
6 {
7 ret void;
8 }
9
10 define void @f2(i8 signext)
11 ; CHECK: define void @f2(i8 signext)
4 define void @f1(i8 zeroext %0)
5 ; CHECK: define void @f1(i8 zeroext %0)
6 {
7 ret void;
8 }
9
10 define void @f2(i8 signext %0)
11 ; CHECK: define void @f2(i8 signext %0)
1212 {
1313 ret void;
1414 }
1919 ret void;
2020 }
2121
22 define void @f4(i8 inreg)
23 ; CHECK: define void @f4(i8 inreg)
24 {
25 ret void;
26 }
27
28 define void @f5(i8* sret)
29 ; CHECK: define void @f5(i8* sret)
22 define void @f4(i8 inreg %0)
23 ; CHECK: define void @f4(i8 inreg %0)
24 {
25 ret void;
26 }
27
28 define void @f5(i8* sret %0)
29 ; CHECK: define void @f5(i8* sret %0)
3030 {
3131 ret void;
3232 }
3737 ret void;
3838 }
3939
40 define void @f7(i8* noalias)
41 ; CHECK: define void @f7(i8* noalias)
42 {
43 ret void;
44 }
45
46 define void @f8(i8* byval)
47 ; CHECK: define void @f8(i8* byval(i8))
48 {
49 ret void;
50 }
51
52 define void @f9(i8* nest)
53 ; CHECK: define void @f9(i8* nest)
40 define void @f7(i8* noalias %0)
41 ; CHECK: define void @f7(i8* noalias %0)
42 {
43 ret void;
44 }
45
46 define void @f8(i8* byval %0)
47 ; CHECK: define void @f8(i8* byval(i8) %0)
48 {
49 ret void;
50 }
51
52 define void @f9(i8* nest %0)
53 ; CHECK: define void @f9(i8* nest %0)
5454 {
5555 ret void;
5656 }
9797 ret void;
9898 }
9999
100 define void @f17(i8 align 4)
101 ; CHECK: define void @f17(i8 align 4)
102 {
103 ret void;
104 }
105
106 define void @f18(i8* nocapture)
107 ; CHECK: define void @f18(i8* nocapture)
100 define void @f17(i8 align 4 %0)
101 ; CHECK: define void @f17(i8 align 4 %0)
102 {
103 ret void;
104 }
105
106 define void @f18(i8* nocapture %0)
107 ; CHECK: define void @f18(i8* nocapture %0)
108108 {
109109 ret void;
110110 }
213213 ret void;
214214 }
215215
216 define void @f36(i8* inalloca) {
217 ; CHECK: define void @f36(i8* inalloca) {
216 define void @f36(i8* inalloca %0) {
217 ; CHECK: define void @f36(i8* inalloca %0) {
218218 ret void
219219 }
220220
239239 ret i8* %a
240240 }
241241
242 define void @f41(i8* align 32, double* align 64) {
243 ; CHECK: define void @f41(i8* align 32, double* align 64) {
242 define void @f41(i8* align 32 %0, double* align 64 %1) {
243 ; CHECK: define void @f41(i8* align 32 %0, double* align 64 %1) {
244244 ret void
245245 }
246246
261261 ret void;
262262 }
263263
264 ; CHECK: define "string_attribute" void @f45(i32 "string_attribute")
265 define "string_attribute" void @f45(i32 "string_attribute") {
266 ret void
267 }
268
269 ; CHECK: define "string_attribute_with_value"="value" void @f46(i32 "string_attribute_with_value"="value")
270 define "string_attribute_with_value"="value" void @f46(i32 "string_attribute_with_value"="value") {
264 ; CHECK: define "string_attribute" void @f45(i32 "string_attribute" %0)
265 define "string_attribute" void @f45(i32 "string_attribute" %0) {
266 ret void
267 }
268
269 ; CHECK: define "string_attribute_with_value"="value" void @f46(i32 "string_attribute_with_value"="value" %0)
270 define "string_attribute_with_value"="value" void @f46(i32 "string_attribute_with_value"="value" %0) {
271271 ret void
272272 }
273273
286286 ret void
287287 }
288288
289 ; CHECK: define void @f50(i8* swiftself)
290 define void @f50(i8* swiftself)
289 ; CHECK: define void @f50(i8* swiftself %0)
290 define void @f50(i8* swiftself %0)
291291 {
292292 ret void;
293293 }
294294
295 ; CHECK: define i32 @f51(i8** swifterror)
296 define i32 @f51(i8** swifterror)
295 ; CHECK: define i32 @f51(i8** swifterror %0)
296 define i32 @f51(i8** swifterror %0)
297297 {
298298 ret i32 0
299299 }
300300
301 ; CHECK: define i32 @f52(i32, i8** swifterror)
302 define i32 @f52(i32, i8** swifterror)
301 ; CHECK: define i32 @f52(i32 %0, i8** swifterror %1)
302 define i32 @f52(i32 %0, i8** swifterror %1)
303303 {
304304 ret i32 0
305305 }
317317 ret float 1.0
318318 }
319319
320 ; CHECK: define i8* @f54(i32) #30
321 define i8* @f54(i32) allocsize(0) {
320 ; CHECK: define i8* @f54(i32 %0) #30
321 define i8* @f54(i32 %0) allocsize(0) {
322322 ret i8* null
323323 }
324324
325 ; CHECK: define i8* @f55(i32, i32) #31
326 define i8* @f55(i32, i32) allocsize(0, 1) {
325 ; CHECK: define i8* @f55(i32 %0, i32 %1) #31
326 define i8* @f55(i32 %0, i32 %1) allocsize(0, 1) {
327327 ret i8* null
328328 }
329329
0 ; RUN: llvm-dis < %s.bc | FileCheck %s
11
2 ; CHECK: define avr_intrcc void @foo(i8)
3 define avr_intrcc void @foo(i8) {
2 ; CHECK: define avr_intrcc void @foo(i8 %0)
3 define avr_intrcc void @foo(i8 %0) {
44 ret void
55 }
66
7 ; CHECK: define avr_signalcc void @bar(i8)
8 define avr_signalcc void @bar(i8) {
7 ; CHECK: define avr_signalcc void @bar(i8 %0)
8 define avr_signalcc void @bar(i8 %0) {
99 ret void
1010 }
1111
12 ; CHECK: define void @baz(i8)
13 define void @baz(i8) {
12 ; CHECK: define void @baz(i8 %0)
13 define void @baz(i8 %0) {
1414 ret void
1515 }
55 ; CHECK-LABEL: define private %void_one_out_non_private_arg_i32_1_use @void_one_out_non_private_arg_i32_1_use.body(i32 addrspace(1)* %val) #0 {
66 ; CHECK-NEXT: ret %void_one_out_non_private_arg_i32_1_use zeroinitializer
77
8 ; CHECK-LABEL: define void @void_one_out_non_private_arg_i32_1_use(i32 addrspace(1)*) #1 {
8 ; CHECK-LABEL: define void @void_one_out_non_private_arg_i32_1_use(i32 addrspace(1)* %0) #1 {
99 ; CHECK-NEXT: %2 = call %void_one_out_non_private_arg_i32_1_use @void_one_out_non_private_arg_i32_1_use.body(i32 addrspace(1)* undef)
1010 ; CHECK-NEXT: %3 = extractvalue %void_one_out_non_private_arg_i32_1_use %2, 0
1111 ; CHECK-NEXT: store i32 %3, i32 addrspace(1)* %0, align 4
2222 ; CHECK-NEXT: %2 = insertvalue %bitcast_pointer_as1 undef, <3 x i32> %1, 0
2323 ; CHECK-NEXT: ret %bitcast_pointer_as1 %2
2424
25 ; CHECK-LABEL: define void @bitcast_pointer_as1(<3 x i32> addrspace(1)*) #1 {
25 ; CHECK-LABEL: define void @bitcast_pointer_as1(<3 x i32> addrspace(1)* %0) #1 {
2626 ; CHECK-NEXT: %2 = call %bitcast_pointer_as1 @bitcast_pointer_as1.body(<3 x i32> addrspace(1)* undef)
2727 define void @bitcast_pointer_as1(<3 x i32> addrspace(1)* %out) #0 {
2828 %load = load volatile <4 x i32>, <4 x i32> addrspace(1)* undef
152152 ; CHECK: ret1:
153153 ; CHECK-NEXT: ret %void_one_out_arg_i32_2_use { i32 9 }
154154
155 ; CHECK-LABEL: define void @void_one_out_arg_i32_2_use(i1, i32*) #2 {
155 ; CHECK-LABEL: define void @void_one_out_arg_i32_2_use(i1 %0, i32* %1) #2 {
156156 ; CHECK-NEXT: %3 = call %void_one_out_arg_i32_2_use @void_one_out_arg_i32_2_use.body(i1 %0, i32* undef)
157157 ; CHECK-NEXT: %4 = extractvalue %void_one_out_arg_i32_2_use %3, 0
158158 ; CHECK-NEXT: store i32 %4, i32* %1, align 4
175175 ; CHECK-NEXT: store i32 0, i32* %val
176176 ; CHECK-NEXT: ret %void_one_out_arg_i32_2_stores { i32 1 }
177177
178 ; CHECK-LABEL: define void @void_one_out_arg_i32_2_stores(i32*) #2 {
178 ; CHECK-LABEL: define void @void_one_out_arg_i32_2_stores(i32* %0) #2 {
179179 ; CHECK-NEXT: %2 = call %void_one_out_arg_i32_2_stores @void_one_out_arg_i32_2_stores.body(i32* undef)
180180 ; CHECK-NEXT: %3 = extractvalue %void_one_out_arg_i32_2_stores %2, 0
181181 ; CHECK-NEXT: store i32 %3, i32* %0, align 4
190190 ; CHECK-NEXT: call void @may.clobber()
191191 ; CHECK-NEXT: ret %void_one_out_arg_i32_2_stores_clobber { i32 1 }
192192
193 ; CHECK-LABEL: define void @void_one_out_arg_i32_2_stores_clobber(i32*) #2 {
193 ; CHECK-LABEL: define void @void_one_out_arg_i32_2_stores_clobber(i32* %0) #2 {
194194 ; CHECK-NEXT: %2 = call %void_one_out_arg_i32_2_stores_clobber @void_one_out_arg_i32_2_stores_clobber.body(i32* undef)
195195 ; CHECK-NEXT: %3 = extractvalue %void_one_out_arg_i32_2_stores_clobber %2, 0
196196 ; CHECK-NEXT: store i32 %3, i32* %0, align 4
218218 ; CHECK-NEXT: call void @may.clobber()
219219 ; CHECK-NEXT: ret %void_one_out_arg_i32_pre_call_may_clobber zeroinitializer
220220
221 ; CHECK-LABEL: @void_one_out_arg_i32_pre_call_may_clobber(i32*) #2 {
221 ; CHECK-LABEL: @void_one_out_arg_i32_pre_call_may_clobber(i32* %0) #2 {
222222 ; CHECK-NEXT: %2 = call %void_one_out_arg_i32_pre_call_may_clobber @void_one_out_arg_i32_pre_call_may_clobber.body(i32* undef)
223223 ; CHECK-NEXT: %3 = extractvalue %void_one_out_arg_i32_pre_call_may_clobber %2, 0
224224 ; CHECK-NEXT: store i32 %3, i32* %0, align 4
277277 ; CHECK-LABEL: define private %void_one_out_arg_v2i32_1_use @void_one_out_arg_v2i32_1_use.body(<2 x i32>* %val) #0 {
278278 ; CHECK-NEXT: ret %void_one_out_arg_v2i32_1_use { <2 x i32> }
279279
280 ; CHECK-LABEL: define void @void_one_out_arg_v2i32_1_use(<2 x i32>*) #2 {
280 ; CHECK-LABEL: define void @void_one_out_arg_v2i32_1_use(<2 x i32>* %0) #2 {
281281 ; CHECK-NEXT: %2 = call %void_one_out_arg_v2i32_1_use @void_one_out_arg_v2i32_1_use.body(<2 x i32>* undef)
282282 ; CHECK-NEXT: %3 = extractvalue %void_one_out_arg_v2i32_1_use %2, 0
283283 ; CHECK-NEXT: store <2 x i32> %3, <2 x i32>* %0, align 8
293293 ; CHECK-NEXT: ret %void_one_out_arg_struct_1_use { %struct { i32 9, i8 99, float 4.000000e+00 } }
294294
295295 ; Normally this is split into element accesses which we don't handle.
296 ; CHECK-LABEL: define void @void_one_out_arg_struct_1_use(%struct*) #2 {
296 ; CHECK-LABEL: define void @void_one_out_arg_struct_1_use(%struct* %0) #2 {
297297 ; CHECK-NEXT: %2 = call %void_one_out_arg_struct_1_use @void_one_out_arg_struct_1_use.body(%struct* undef)
298298 ; CHECK-NEXT: %3 = extractvalue %void_one_out_arg_struct_1_use %2, 0
299299 ; CHECK-NEXT: store %struct %3, %struct* %0, align 4
306306 ; CHECK-LABEL: define private %i32_one_out_arg_i32_1_use @i32_one_out_arg_i32_1_use.body(i32* %val) #0 {
307307 ; CHECK-NEXT: ret %i32_one_out_arg_i32_1_use { i32 9, i32 24 }
308308
309 ; CHECK-LABEL: define i32 @i32_one_out_arg_i32_1_use(i32*) #2 {
309 ; CHECK-LABEL: define i32 @i32_one_out_arg_i32_1_use(i32* %0) #2 {
310310 ; CHECK-NEXT: %2 = call %i32_one_out_arg_i32_1_use @i32_one_out_arg_i32_1_use.body(i32* undef)
311311 ; CHECK-NEXT: %3 = extractvalue %i32_one_out_arg_i32_1_use %2, 1
312312 ; CHECK-NEXT: store i32 %3, i32* %0, align 4
320320 ; CHECK-LABEL: define private %unused_different_type @unused_different_type.body(i32* %arg0, float* nocapture %arg1) #0 {
321321 ; CHECK-NEXT: ret %unused_different_type { float 4.000000e+00 }
322322
323 ; CHECK-LABEL: define void @unused_different_type(i32*, float* nocapture) #2 {
323 ; CHECK-LABEL: define void @unused_different_type(i32* %0, float* nocapture %1) #2 {
324324 ; CHECK-NEXT: %3 = call %unused_different_type @unused_different_type.body(i32* %0, float* undef)
325325 ; CHECK-NEXT: %4 = extractvalue %unused_different_type %3, 0
326326 ; CHECK-NEXT: store float %4, float* %1, align 4
349349 ; CHECK-LABEL: define private %multiple_same_return_mayalias @multiple_same_return_mayalias.body(i32* %out0, i32* %out1) #0 {
350350 ; CHECK-NEXT: ret %multiple_same_return_mayalias { i32 2, i32 1 }
351351
352 ; CHECK-LABEL: define void @multiple_same_return_mayalias(i32*, i32*) #2 {
352 ; CHECK-LABEL: define void @multiple_same_return_mayalias(i32* %0, i32* %1) #2 {
353353 ; CHECK-NEXT: %3 = call %multiple_same_return_mayalias @multiple_same_return_mayalias.body(i32* undef, i32* undef)
354354 ; CHECK-NEXT: %4 = extractvalue %multiple_same_return_mayalias %3, 0
355355 ; CHECK-NEXT: store i32 %4, i32* %0, align 4
365365 ; CHECK-LABEL: define private %multiple_same_return_mayalias_order @multiple_same_return_mayalias_order.body(i32* %out0, i32* %out1) #0 {
366366 ; CHECK-NEXT: ret %multiple_same_return_mayalias_order { i32 1, i32 2 }
367367
368 ; CHECK-LABEL: define void @multiple_same_return_mayalias_order(i32*, i32*) #2 {
368 ; CHECK-LABEL: define void @multiple_same_return_mayalias_order(i32* %0, i32* %1) #2 {
369369 ; CHECK-NEXT: %3 = call %multiple_same_return_mayalias_order @multiple_same_return_mayalias_order.body(i32* undef, i32* undef)
370370 ; CHECK-NEXT: %4 = extractvalue %multiple_same_return_mayalias_order %3, 0
371371 ; CHECK-NEXT: store i32 %4, i32* %0, align 4
400400 ; CHECK-LABEL: define private %i1_one_out_arg_i32_1_use @i1_one_out_arg_i32_1_use.body(i32* %val) #0 {
401401 ; CHECK-NEXT: ret %i1_one_out_arg_i32_1_use { i1 true, i32 24 }
402402
403 ; CHECK-LABEL: define i1 @i1_one_out_arg_i32_1_use(i32*) #2 {
403 ; CHECK-LABEL: define i1 @i1_one_out_arg_i32_1_use(i32* %0) #2 {
404404 ; CHECK: %2 = call %i1_one_out_arg_i32_1_use @i1_one_out_arg_i32_1_use.body(i32* undef)
405405 ; CHECK: %3 = extractvalue %i1_one_out_arg_i32_1_use %2, 1
406406 ; CHECK: store i32 %3, i32* %0, align 4
417417 ; CHECK-LABEL: define private %i1_zeroext_one_out_arg_i32_1_use @i1_zeroext_one_out_arg_i32_1_use.body(i32* %val) #0 {
418418 ; CHECK-NEXT: ret %i1_zeroext_one_out_arg_i32_1_use { i1 true, i32 24 }
419419
420 ; CHECK-LABEL: define zeroext i1 @i1_zeroext_one_out_arg_i32_1_use(i32*) #2 {
420 ; CHECK-LABEL: define zeroext i1 @i1_zeroext_one_out_arg_i32_1_use(i32* %0) #2 {
421421 ; CHECK-NEXT: %2 = call %i1_zeroext_one_out_arg_i32_1_use @i1_zeroext_one_out_arg_i32_1_use.body(i32* undef)
422422 ; CHECK-NEXT: %3 = extractvalue %i1_zeroext_one_out_arg_i32_1_use %2, 1
423423 ; CHECK-NEXT: store i32 %3, i32* %0, align 4
431431 ; CHECK-LABEL: define private %i1_signext_one_out_arg_i32_1_use @i1_signext_one_out_arg_i32_1_use.body(i32* %val) #0 {
432432 ; CHECK-NEXT: ret %i1_signext_one_out_arg_i32_1_use { i1 true, i32 24 }
433433
434 ; CHECK-LABEL: define signext i1 @i1_signext_one_out_arg_i32_1_use(i32*) #2 {
434 ; CHECK-LABEL: define signext i1 @i1_signext_one_out_arg_i32_1_use(i32* %0) #2 {
435435 ; CHECK-NEXT: %2 = call %i1_signext_one_out_arg_i32_1_use @i1_signext_one_out_arg_i32_1_use.body(i32* undef)
436436 ; CHECK-NEXT: %3 = extractvalue %i1_signext_one_out_arg_i32_1_use %2, 1
437437 ; CHECK-NEXT: store i32 %3, i32* %0, align 4
445445 ; CHECK-LABEL: define private %p1i32_noalias_one_out_arg_i32_1_use @p1i32_noalias_one_out_arg_i32_1_use.body(i32* %val) #0 {
446446 ; CHECK-NEXT: ret %p1i32_noalias_one_out_arg_i32_1_use { i32 addrspace(1)* null, i32 24 }
447447
448 ; CHECK-LABEL: define noalias i32 addrspace(1)* @p1i32_noalias_one_out_arg_i32_1_use(i32*) #2 {
448 ; CHECK-LABEL: define noalias i32 addrspace(1)* @p1i32_noalias_one_out_arg_i32_1_use(i32* %0) #2 {
449449 ; CHECK-NEXT: %2 = call %p1i32_noalias_one_out_arg_i32_1_use @p1i32_noalias_one_out_arg_i32_1_use.body(i32* undef)
450450 ; CHECK-NEXT: %3 = extractvalue %p1i32_noalias_one_out_arg_i32_1_use %2, 1
451451 ; CHECK-NEXT: store i32 %3, i32* %0, align 4
465465 }
466466
467467 ; CHECK-LABEL: define private %func_ptr_type @func_ptr_type.body(void ()** %out) #0 {
468 ; CHECK-LABEL: define void @func_ptr_type(void ()**) #2 {
468 ; CHECK-LABEL: define void @func_ptr_type(void ()** %0) #2 {
469469 ; CHECK: %2 = call %func_ptr_type @func_ptr_type.body(void ()** undef)
470470 define void @func_ptr_type(void()** %out) #0 {
471471 %func = load void()*, void()** undef
474474 }
475475
476476 ; CHECK-LABEL: define private %bitcast_func_ptr_type @bitcast_func_ptr_type.body(void ()** %out) #0 {
477 ; CHECK-LABEL: define void @bitcast_func_ptr_type(void ()**) #2 {
477 ; CHECK-LABEL: define void @bitcast_func_ptr_type(void ()** %0) #2 {
478478 define void @bitcast_func_ptr_type(void()** %out) #0 {
479479 %func = load i32()*, i32()** undef
480480 %cast = bitcast void()** %out to i32()**
485485 ; CHECK-LABEL: define private %out_arg_small_array @out_arg_small_array.body([4 x i32]* %val) #0 {
486486 ; CHECK-NEXT: ret %out_arg_small_array { [4 x i32] [i32 0, i32 1, i32 2, i32 3] }
487487
488 ; CHECK-LABEL: define void @out_arg_small_array([4 x i32]*) #2 {
488 ; CHECK-LABEL: define void @out_arg_small_array([4 x i32]* %0) #2 {
489489 define void @out_arg_small_array([4 x i32]* %val) #0 {
490490 store [4 x i32] [i32 0, i32 1, i32 2, i32 3], [4 x i32]* %val
491491 ret void
509509 }
510510
511511 ; CHECK-LABEL: define private %num_regs_reach_limit @num_regs_reach_limit.body(i32* %out, i32 %val) #0 {
512 ; CHECK: define [15 x i32] @num_regs_reach_limit(i32*, i32) #2 {
512 ; CHECK: define [15 x i32] @num_regs_reach_limit(i32* %0, i32 %1) #2 {
513513 ; CHECK-NEXT: call %num_regs_reach_limit @num_regs_reach_limit.body(i32* undef, i32 %1)
514514 define [15 x i32] @num_regs_reach_limit(i32* %out, i32 %val) #0 {
515515 %load = load volatile [15 x i32], [15 x i32] addrspace(1)* undef
525525 ; CHECK-NEXT: %3 = insertvalue %num_regs_reach_limit_leftover %2, i32 %val0, 2
526526 ; CHECK-NEXT: ret %num_regs_reach_limit_leftover %3
527527
528 ; CHECK-LABEL: define [15 x i32] @num_regs_reach_limit_leftover(i32*, i32*, i32) #2 {
528 ; CHECK-LABEL: define [15 x i32] @num_regs_reach_limit_leftover(i32* %0, i32* %1, i32 %2) #2 {
529529 ; CHECK-NEXT: %4 = call %num_regs_reach_limit_leftover @num_regs_reach_limit_leftover.body(i32* undef, i32* undef, i32 %2)
530530 ; CHECK-NEXT: %5 = extractvalue %num_regs_reach_limit_leftover %4, 1
531531 ; CHECK-NEXT: store i32 %5, i32* %0, align 4
546546 ; CHECK-NEXT: %1 = insertvalue %preserve_debug_info undef, i32 %arg0, 0, !dbg !11
547547 ; CHECK-NEXT: ret %preserve_debug_info %1, !dbg !11
548548
549 ; CHECK-LABEL: define void @preserve_debug_info(i32, i32*) #2 !dbg !6 {
549 ; CHECK-LABEL: define void @preserve_debug_info(i32 %0, i32* %1) #2 !dbg !6 {
550550 ; CHECK-NEXT: %3 = call %preserve_debug_info @preserve_debug_info.body(i32 %0, i32* undef){{$}}
551551 ; CHECK-NEXT: %4 = extractvalue %preserve_debug_info %3, 0{{$}}
552552 ; CHECK-NEXT: store i32 %4, i32* %1, align 4{{$}}
571571 ; CHECK-NEXT: %2 = insertvalue %bitcast_pointer_v4i32_v3i32 undef, <3 x i32> %1, 0
572572 ; CHECK-NEXT: ret %bitcast_pointer_v4i32_v3i32 %2
573573
574 ; CHECK-LABEL: define void @bitcast_pointer_v4i32_v3i32(<3 x i32>*) #2 {
574 ; CHECK-LABEL: define void @bitcast_pointer_v4i32_v3i32(<3 x i32>* %0) #2 {
575575 ; CHECK-NEXT: %2 = call %bitcast_pointer_v4i32_v3i32 @bitcast_pointer_v4i32_v3i32.body(<3 x i32>* undef)
576576 ; CHECK-NEXT: %3 = extractvalue %bitcast_pointer_v4i32_v3i32 %2, 0
577577 ; CHECK-NEXT: store <3 x i32> %3, <3 x i32>* %0, align 16
608608 ; CHECK-NEXT: %2 = insertvalue %bitcast_pointer_i32_f32 undef, float %1, 0
609609 ; CHECK-NEXT: ret %bitcast_pointer_i32_f32 %2
610610
611 ; CHECK-LABEL: define void @bitcast_pointer_i32_f32(float*) #2 {
611 ; CHECK-LABEL: define void @bitcast_pointer_i32_f32(float* %0) #2 {
612612 ; CHECK-NEXT: %2 = call %bitcast_pointer_i32_f32 @bitcast_pointer_i32_f32.body(float* undef)
613613 ; CHECK-NEXT: %3 = extractvalue %bitcast_pointer_i32_f32 %2, 0
614614 ; CHECK-NEXT: store float %3, float* %0, align 4
651651 ; CHECK-NEXT: %3 = insertvalue %bitcast_struct_v3f32_v3f32 undef, %struct.v3f32 %2, 0
652652 ; CHECK-NEXT: ret %bitcast_struct_v3f32_v3f32 %3
653653
654 ; CHECK-LABEL: define void @bitcast_struct_v3f32_v3f32(%struct.v3f32*, <3 x float>) #2 {
654 ; CHECK-LABEL: define void @bitcast_struct_v3f32_v3f32(%struct.v3f32* %0, <3 x float> %1) #2 {
655655 ; CHECK-NEXT: %3 = call %bitcast_struct_v3f32_v3f32 @bitcast_struct_v3f32_v3f32.body(%struct.v3f32* undef, <3 x float> %1)
656656 ; CHECK-NEXT: %4 = extractvalue %bitcast_struct_v3f32_v3f32 %3, 0
657657 ; CHECK-NEXT: store %struct.v3f32 %4, %struct.v3f32* %0, align 16
672672 ; CHECK-NEXT: %4 = insertvalue %bitcast_struct_v3f32_v3i32 undef, %struct.v3f32 %3, 0
673673 ; CHECK-NEXT: ret %bitcast_struct_v3f32_v3i32 %4
674674
675 ; CHECK-LABEL: define void @bitcast_struct_v3f32_v3i32(%struct.v3f32*, <3 x i32>) #2 {
675 ; CHECK-LABEL: define void @bitcast_struct_v3f32_v3i32(%struct.v3f32* %0, <3 x i32> %1) #2 {
676676 ; CHECK-NEXT: %3 = call %bitcast_struct_v3f32_v3i32 @bitcast_struct_v3f32_v3i32.body(%struct.v3f32* undef, <3 x i32> %1)
677677 ; CHECK-NEXT: %4 = extractvalue %bitcast_struct_v3f32_v3i32 %3, 0
678678 ; CHECK-NEXT: store %struct.v3f32 %4, %struct.v3f32* %0, align 16
689689 ; CHECK-NEXT: %2 = insertvalue %bitcast_struct_v4f32_v4f32 undef, %struct.v4f32 %1, 0
690690 ; CHECK-NEXT: ret %bitcast_struct_v4f32_v4f32 %2
691691
692 ; CHECK-LABEL: define void @bitcast_struct_v4f32_v4f32(%struct.v4f32*, <4 x float>) #2 {
692 ; CHECK-LABEL: define void @bitcast_struct_v4f32_v4f32(%struct.v4f32* %0, <4 x float> %1) #2 {
693693 ; CHECK-NEXT: %3 = call %bitcast_struct_v4f32_v4f32 @bitcast_struct_v4f32_v4f32.body(%struct.v4f32* undef, <4 x float> %1)
694694 define void @bitcast_struct_v4f32_v4f32(%struct.v4f32* %out, <4 x float> %value) #0 {
695695 %cast = bitcast %struct.v4f32* %out to <4 x float>*
698698 }
699699
700700 ; CHECK-LABEL: define private %bitcast_struct_v3f32_v4i32 @bitcast_struct_v3f32_v4i32.body(%struct.v3f32* %out, <4 x i32> %value) #0 {
701 ; CHECK-LABEL: define void @bitcast_struct_v3f32_v4i32(%struct.v3f32*, <4 x i32>) #2 {
701 ; CHECK-LABEL: define void @bitcast_struct_v3f32_v4i32(%struct.v3f32* %0, <4 x i32> %1) #2 {
702702 define void @bitcast_struct_v3f32_v4i32(%struct.v3f32* %out, <4 x i32> %value) #0 {
703703 %cast = bitcast %struct.v3f32* %out to <4 x i32>*
704704 store <4 x i32> %value, <4 x i32>* %cast, align 16
706706 }
707707
708708 ; CHECK-LABEL: define private %bitcast_struct_v4f32_v3f32 @bitcast_struct_v4f32_v3f32.body(%struct.v4f32* %out, <3 x float> %value) #0 {
709 ; CHECK-LABEL: define void @bitcast_struct_v4f32_v3f32(%struct.v4f32*, <3 x float>) #2 {
709 ; CHECK-LABEL: define void @bitcast_struct_v4f32_v3f32(%struct.v4f32* %0, <3 x float> %1) #2 {
710710 define void @bitcast_struct_v4f32_v3f32(%struct.v4f32* %out, <3 x float> %value) #0 {
711711 %extractVec = shufflevector <3 x float> %value, <3 x float> undef, <4 x i32>
712712 %cast = bitcast %struct.v4f32* %out to <4 x float>*
754754 ret void
755755 }
756756
757 ; CHECK-LABEL: define void @bitcast_struct_i128_v4f32(%struct.i128*, <4 x float>) #2 {
757 ; CHECK-LABEL: define void @bitcast_struct_i128_v4f32(%struct.i128* %0, <4 x float> %1) #2 {
758758 ; CHECK-NEXT: %3 = call %bitcast_struct_i128_v4f32 @bitcast_struct_i128_v4f32.body(%struct.i128* undef, <4 x float> %1)
759759 define void @bitcast_array_v4i32_v4f32([4 x i32]* %out, [4 x float] %value) #0 {
760760 %cast = bitcast [4 x i32]* %out to [4 x float]*
1313 declare void @g()
1414 declare i32 @__CxxFrameHandler3(...)
1515
16 ; CHECK: define internal i32 @"__ehhandler$f"(i8*, i8*, i8*, i8*){{ .+}} comdat($f) {
16 ; CHECK: define internal i32 @"__ehhandler$f"(i8* %0, i8* %1, i8* %2, i8* %3){{ .+}} comdat($f) {
11 ; RUN: llc < %s | FileCheck %s --check-prefix=ASM
22
33 ; IR-NOT: define.*__ehhandler
4 ; IR: define available_externally void @foo(void ()*)
4 ; IR: define available_externally void @foo(void ()* %0)
55 ; IR-NOT: define.*__ehhandler
66
77 ; No code should be emitted.
99 ; CHECK: ret i32 %add
1010
1111 ; NONAME: @GlobalValueName
12 ; NONAME: @foo(i32)
12 ; NONAME: @foo(i32 %0)
1313 ; NONAME-NOT: somelabel:
1414 ; NONAME: %2 = load i32, i32* @GlobalValueName
1515 ; NONAME: %3 = add i32 %0, %2
1212 ret i32 %c
1313 }
1414
15 ; CHECK: define i32 (i32, i32)* @discardg(i32)
15 ; CHECK: define i32 (i32, i32)* @discardg(i32 %0)
1616 ; CHECK: %[[CALL:.*]] = call { i32 (i32, i32)*, i16 } @"dfs$g"(i32 %0, i16 0)
1717 ; CHECK: %[[XVAL:.*]] = extractvalue { i32 (i32, i32)*, i16 } %[[CALL]], 0
1818 ; CHECK: ret {{.*}} %[[XVAL]]
2020
2121 declare void @custom1(i32 %a, i32 %b)
2222
23 ; CHECK: define linkonce_odr { i32, i16 } @"dfsw$custom2"(i32, i32, i16, i16)
23 ; CHECK: define linkonce_odr { i32, i16 } @"dfsw$custom2"(i32 %0, i32 %1, i16 %2, i16 %3)
2424 ; CHECK: %[[LABELRETURN2:.*]] = alloca i16
2525 ; CHECK: %[[RV:.*]] = call i32 @__dfsw_custom2
2626 ; CHECK: %[[RVSHADOW:.*]] = load i16, i16* %[[LABELRETURN2]]
2929 ; CHECK: ret { i32, i16 }
3030 declare i32 @custom2(i32 %a, i32 %b)
3131
32 ; CHECK: define linkonce_odr void @"dfsw$custom3"(i32, i16, i16*, ...)
32 ; CHECK: define linkonce_odr void @"dfsw$custom3"(i32 %0, i16 %1, i16* %2, ...)
3333 ; CHECK: call void @__dfsan_vararg_wrapper(i8*
3434 ; CHECK: unreachable
3535 declare void @custom3(i32 %a, ...)
7777 ret i32 (i32, i32)* @custom2
7878 }
7979
80 ; CHECK: define { i32, i16 } @"dfs$adiscard"(i32, i32, i16, i16)
80 ; CHECK: define { i32, i16 } @"dfs$adiscard"(i32 %0, i32 %1, i16 %2, i16 %3)
8181 ; CHECK: %[[CALL:.*]] = call i32 @discard(i32 %0, i32 %1)
8282 ; CHECK: %[[IVAL0:.*]] = insertvalue { i32, i16 } undef, i32 %[[CALL]], 0
8383 ; CHECK: %[[IVAL1:.*]] = insertvalue { i32, i16 } %[[IVAL0]], i16 0, 1
8787 ; CHECK: declare void @__dfsw_custom1(i32, i32, i16, i16)
8888 ; CHECK: declare i32 @__dfsw_custom2(i32, i32, i16, i16, i16*)
8989
90 ; CHECK-LABEL: define linkonce_odr i32 @"dfst0$customcb"(i32 (i32)*, i32, i16, i16*)
90 ; CHECK-LABEL: define linkonce_odr i32 @"dfst0$customcb"(i32 (i32)* %0, i32 %1, i16 %2, i16* %3)
9191 ; CHECK: %[[BC:.*]] = bitcast i32 (i32)* %0 to { i32, i16 } (i32, i16)*
9292 ; CHECK: %[[CALL:.*]] = call { i32, i16 } %[[BC]](i32 %1, i16 %2)
9393 ; CHECK: %[[XVAL0:.*]] = extractvalue { i32, i16 } %[[CALL]], 0
33
44 declare i32 @g()
55
6 ; CHECK: define { i32, i16 } @"dfs$f"(i32, i32, i16, i16)
6 ; CHECK: define { i32, i16 } @"dfs$f"(i32 %0, i32 %1, i16 %2, i16 %3)
77 define i32 @f(i32, i32) {
88 ; CHECK: [[LOCALLABELALLOCA:%.*]] = alloca i16
99 %i = alloca i32
44 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1)
55
66 define void @ms(i8* %p, i8 %v) {
7 ; CHECK-LABEL: @"dfs$ms"(i8*, i8, i16, i16)
7 ; CHECK-LABEL: @"dfs$ms"(i8* %0, i8 %1, i16 %2, i16 %3)
88 ; CHECK: call void @__dfsan_set_label(i16 %3, i8* %0, i64 1)
99 call void @llvm.memset.p0i8.i64(i8* %p, i8 %v, i64 1, i1 1)
1010 ret void
6969 ; CHECK-DAG: @a23 = alias i32 (i8*), i32 (i8*)* @f1.2{{$}}
7070 ; CHECK-DAG: @a24 = alias i16, bitcast (i32 (i8*)* @f1.2 to i16*)
7171
72 ; CHECK: define weak_odr dso_local i32 @f1(i8*) comdat($c1) {
72 ; CHECK: define weak_odr dso_local i32 @f1(i8* %0) comdat($c1) {
7373 ; CHECK-NEXT: bb10:
7474 ; CHECK-NEXT: br label %bb11{{$}}
7575 ; CHECK: bb11:
4646 ; CHECK-DAG: @a23 = alias i32 (i8*), i32 (i8*)* @f1.2{{$}}
4747 ; CHECK-DAG: @a24 = alias i16, bitcast (i32 (i8*)* @f1.2 to i16*)
4848
49 ; CHECK: define weak_odr protected i32 @f1(i8*) comdat($c1) {
49 ; CHECK: define weak_odr protected i32 @f1(i8* %0) comdat($c1) {
5050 ; CHECK-NEXT: bb10:
5151 ; CHECK-NEXT: br label %bb11{{$}}
5252 ; CHECK: bb11:
99 ; Copy from first module is prevailing and converted to weak_odr, copy
1010 ; from second module is preempted and converted to available_externally and
1111 ; removed from comdat.
12 ; IMPORT1: define weak_odr i32 @f(i8*) unnamed_addr comdat($c1) {
13 ; IMPORT2: define available_externally i32 @f(i8*) unnamed_addr {
12 ; IMPORT1: define weak_odr i32 @f(i8* %0) unnamed_addr comdat($c1) {
13 ; IMPORT2: define available_externally i32 @f(i8* %0) unnamed_addr {
1414
1515 ; RUN: llvm-nm -o - < %t1.bc.thinlto.o | FileCheck %s --check-prefix=NM1
1616 ; NM1: W f
55 ; RUN: opt -S -argpromotion %s | FileCheck --check-prefix=THIS %s
66 ; RUN: opt -S -globalopt -argpromotion %s | FileCheck --check-prefix=OPT %s
77 ; THIS: define internal x86_thiscallcc void @internalfun(%struct.a* %this, <{ %struct.a
8 ; OPT: define internal fastcc void @internalfun(<{ %struct.a }>*)
8 ; OPT: define internal fastcc void @internalfun(<{ %struct.a }>* %0)
99
1010 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
1111 target triple = "i386-pc-windows-msvc19.11.0"
1717 unreachable
1818 }
1919
20 ; CHECK: define internal i32 @foo(i32*)
20 ; CHECK: define internal i32 @foo(i32* %0)
2121
2222 attributes #0 = { naked }
4949 ret i8* %n
5050 }
5151
52 ; CHECK-LABEL: define private fastcc void @NoopCoro.ResumeDestroy(%NoopCoro.Frame*) {
52 ; CHECK-LABEL: define private fastcc void @NoopCoro.ResumeDestroy(%NoopCoro.Frame* %0) {
5353 ; CHECK-NEXT: entry
5454 ; CHECK-NEXT: ret void
5555
66
77
88 ; TEST 1
9 ; ATTRIBUTOR: define align 8 i32* @test1(i32* returned align 8)
10 define i32* @test1(i32* align 8) #0 {
9 ; ATTRIBUTOR: define align 8 i32* @test1(i32* returned align 8 %0)
10 define i32* @test1(i32* align 8 %0) #0 {
1111 ret i32* %0
1212 }
1313
1414 ; TEST 2
15 ; ATTRIBUTOR: define i32* @test2(i32* returned)
16 define i32* @test2(i32*) #0 {
15 ; ATTRIBUTOR: define i32* @test2(i32* returned %0)
16 define i32* @test2(i32* %0) #0 {
1717 ret i32* %0
1818 }
1919
2020 ; TEST 3
21 ; ATTRIBUTOR: define align 4 i32* @test3(i32* align 8, i32* align 4, i1)
22 define i32* @test3(i32* align 8, i32* align 4, i1) #0 {
21 ; ATTRIBUTOR: define align 4 i32* @test3(i32* align 8 %0, i32* align 4 %1, i1 %2)
22 define i32* @test3(i32* align 8 %0, i32* align 4 %1, i1 %2) #0 {
2323 %ret = select i1 %2, i32* %0, i32* %1
2424 ret i32* %ret
2525 }
2626
2727 ; TEST 4
28 ; ATTRIBUTOR: define align 32 i32* @test4(i32* align 32, i32* align 32, i1)
29 define i32* @test4(i32* align 32, i32* align 32, i1) #0 {
28 ; ATTRIBUTOR: define align 32 i32* @test4(i32* align 32 %0, i32* align 32 %1, i1 %2)
29 define i32* @test4(i32* align 32 %0, i32* align 32 %1, i1 %2) #0 {
3030 %ret = select i1 %2, i32* %0, i32* %1
3131 ret i32* %ret
3232 }
8181 @a2 = common global i8 0, align 16
8282
8383 ; Function Attrs: nounwind readnone ssp uwtable
84 define internal i8* @f1(i8* readnone) local_unnamed_addr #0 {
85 ; ATTRIBUTOR: define internal nonnull align 8 i8* @f1(i8* nonnull readnone align 8)
84 define internal i8* @f1(i8* readnone %0) local_unnamed_addr #0 {
85 ; ATTRIBUTOR: define internal nonnull align 8 i8* @f1(i8* nonnull readnone align 8 %0)
8686 %2 = icmp eq i8* %0, null
8787 br i1 %2, label %3, label %5
8888
9797 }
9898
9999 ; Function Attrs: nounwind readnone ssp uwtable
100 define internal i8* @f2(i8* readnone) local_unnamed_addr #0 {
101 ; ATTRIBUTOR: define internal nonnull align 8 i8* @f2(i8* nonnull readnone align 8)
100 define internal i8* @f2(i8* readnone %0) local_unnamed_addr #0 {
101 ; ATTRIBUTOR: define internal nonnull align 8 i8* @f2(i8* nonnull readnone align 8 %0)
102102 %2 = icmp eq i8* %0, null
103103 br i1 %2, label %5, label %3
104104
119119 }
120120
121121 ; Function Attrs: nounwind readnone ssp uwtable
122 define internal i8* @f3(i8* readnone) local_unnamed_addr #0 {
123 ; ATTRIBUTOR: define internal nonnull align 8 i8* @f3(i8* nonnull readnone align 16)
122 define internal i8* @f3(i8* readnone %0) local_unnamed_addr #0 {
123 ; ATTRIBUTOR: define internal nonnull align 8 i8* @f3(i8* nonnull readnone align 16 %0)
124124 %2 = icmp eq i8* %0, null
125125 br i1 %2, label %3, label %5
126126
22
33 ; See PR26774
44
5 ; CHECK-LABEL: define void @bar(i8* readonly) {
5 ; CHECK-LABEL: define void @bar(i8* readonly %0) {
66 define void @bar(i8* readonly) {
77 call void @foo(i8* %0)
88 ret void
99 }
1010
1111
12 ; CHECK-LABEL: define linkonce_odr void @foo(i8* readonly) {
12 ; CHECK-LABEL: define linkonce_odr void @foo(i8* readonly %0) {
1313 define linkonce_odr void @foo(i8* readonly) {
1414 call void @bar(i8* %0)
1515 ret void
33 ; TEST 1
44 ; take mininimum of return values
55 ;
6 define i32* @test1(i32* dereferenceable(4), double* dereferenceable(8), i1 zeroext) local_unnamed_addr {
7 ; ATTRIBUTOR: define nonnull dereferenceable(4) i32* @test1(i32* nonnull dereferenceable(4), double* nonnull dereferenceable(8), i1 zeroext)
6 define i32* @test1(i32* dereferenceable(4) %0, double* dereferenceable(8) %1, i1 zeroext %2) local_unnamed_addr {
7 ; ATTRIBUTOR: define nonnull dereferenceable(4) i32* @test1(i32* nonnull dereferenceable(4) %0, double* nonnull dereferenceable(8) %1, i1 zeroext %2)
88 %4 = bitcast double* %1 to i32*
99 %5 = select i1 %2, i32* %0, i32* %4
1010 ret i32* %5
1111 }
1212
1313 ; TEST 2
14 define i32* @test2(i32* dereferenceable_or_null(4), double* dereferenceable(8), i1 zeroext) local_unnamed_addr {
15 ; ATTRIBUTOR: define dereferenceable_or_null(4) i32* @test2(i32* dereferenceable_or_null(4), double* nonnull dereferenceable(8), i1 zeroext)
14 define i32* @test2(i32* dereferenceable_or_null(4) %0, double* dereferenceable(8) %1, i1 zeroext %2) local_unnamed_addr {
15 ; ATTRIBUTOR: define dereferenceable_or_null(4) i32* @test2(i32* dereferenceable_or_null(4) %0, double* nonnull dereferenceable(8) %1, i1 zeroext %2)
1616 %4 = bitcast double* %1 to i32*
1717 %5 = select i1 %2, i32* %0, i32* %4
1818 ret i32* %5
2020
2121 ; TEST 3
2222 ; GEP inbounds
23 define i32* @test3_1(i32* dereferenceable(8)) local_unnamed_addr {
24 ; ATTRIBUTOR: define nonnull dereferenceable(4) i32* @test3_1(i32* nonnull dereferenceable(8))
23 define i32* @test3_1(i32* dereferenceable(8) %0) local_unnamed_addr {
24 ; ATTRIBUTOR: define nonnull dereferenceable(4) i32* @test3_1(i32* nonnull dereferenceable(8) %0)
2525 %ret = getelementptr inbounds i32, i32* %0, i64 1
2626 ret i32* %ret
2727 }
2828
29 define i32* @test3_2(i32* dereferenceable_or_null(32)) local_unnamed_addr {
29 define i32* @test3_2(i32* dereferenceable_or_null(32) %0) local_unnamed_addr {
3030 ; FIXME: Argument should be mark dereferenceable because of GEP `inbounds`.
31 ; ATTRIBUTOR: define nonnull dereferenceable(16) i32* @test3_2(i32* dereferenceable_or_null(32))
31 ; ATTRIBUTOR: define nonnull dereferenceable(16) i32* @test3_2(i32* dereferenceable_or_null(32) %0)
3232 %ret = getelementptr inbounds i32, i32* %0, i64 4
3333 ret i32* %ret
3434 }
3535
36 define i32* @test3_3(i32* dereferenceable(8), i32* dereferenceable(16), i1) local_unnamed_addr {
37 ; ATTRIBUTOR: define nonnull dereferenceable(4) i32* @test3_3(i32* nonnull dereferenceable(8), i32* nonnull dereferenceable(16), i1) local_unnamed_addr
36 define i32* @test3_3(i32* dereferenceable(8) %0, i32* dereferenceable(16) %1, i1 %2) local_unnamed_addr {
37 ; ATTRIBUTOR: define nonnull dereferenceable(4) i32* @test3_3(i32* nonnull dereferenceable(8) %0, i32* nonnull dereferenceable(16) %1, i1 %2) local_unnamed_addr
3838 %ret1 = getelementptr inbounds i32, i32* %0, i64 1
3939 %ret2 = getelementptr inbounds i32, i32* %1, i64 2
4040 %ret = select i1 %2, i32* %ret1, i32* %ret2
4444 ; TEST 4
4545 ; Better than known in IR.
4646
47 define dereferenceable(4) i32* @test4(i32* dereferenceable(8)) local_unnamed_addr {
48 ; ATTRIBUTOR: define nonnull dereferenceable(8) i32* @test4(i32* nonnull returned dereferenceable(8))
47 define dereferenceable(4) i32* @test4(i32* dereferenceable(8) %0) local_unnamed_addr {
48 ; ATTRIBUTOR: define nonnull dereferenceable(8) i32* @test4(i32* nonnull returned dereferenceable(8) %0)
4949 ret i32* %0
5050 }
5151
1616 }
1717
1818 ; CHECK: Function Attrs: nofree norecurse nosync nounwind uwtable willreturn
19 ; CHECK-NEXT: define internal i32 @internal_load(i32* nonnull)
19 ; CHECK-NEXT: define internal i32 @internal_load(i32* nonnull %0)
2020 define internal i32 @internal_load(i32*) norecurse nounwind uwtable {
2121 %2 = load i32, i32* %0, align 4
2222 ret i32 %2
1919 unreachable
2020 }
2121
22 ; CHECK: define internal i32 @foo(i32*)
22 ; CHECK: define internal i32 @foo(i32* %0)
2323
2424 attributes #0 = { naked }
5959 ret i8* %1
6060 }
6161
62 ; CHECK: define noalias i8* @foo1(i32)
63 define i8* @foo1(i32) nounwind uwtable {
62 ; CHECK: define noalias i8* @foo1(i32 %0)
63 define i8* @foo1(i32 %0) nounwind uwtable {
6464 %2 = icmp eq i32 %0, 0
6565 br i1 %2, label %5, label %3
6666
124124
125125 ; TEST 8
126126
127 ; CHECK: define noalias i8* @test8(i32*)
128 define i8* @test8(i32*) nounwind uwtable {
127 ; CHECK: define noalias i8* @test8(i32* %0)
128 define i8* @test8(i32* %0) nounwind uwtable {
129129 %2 = tail call noalias i8* @malloc(i64 4)
130130 %3 = icmp ne i32* %0, null
131131 br i1 %3, label %4, label %5
2828 ; }
2929
3030 ; FNATTR: Function Attrs: noinline nounwind uwtable
31 ; FNATTR-NEXT: define void @only_free(i8* nocapture) local_unnamed_addr
32 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
33 ; ATTRIBUTOR-NOT: nofree
34 ; ATTRIBUTOR-NEXT: define void @only_free(i8* nocapture) local_unnamed_addr #1
35 define void @only_free(i8* nocapture) local_unnamed_addr #0 {
31 ; FNATTR-NEXT: define void @only_free(i8* nocapture %0) local_unnamed_addr
32 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
33 ; ATTRIBUTOR-NOT: nofree
34 ; ATTRIBUTOR-NEXT: define void @only_free(i8* nocapture %0) local_unnamed_addr #1
35 define void @only_free(i8* nocapture %0) local_unnamed_addr #0 {
3636 tail call void @free(i8* %0) #1
3737 ret void
3838 }
5050
5151
5252 ; FNATTR: Function Attrs: noinline nounwind uwtable
53 ; FNATTR-NEXT: define void @free_in_scc1(i8* nocapture) local_unnamed_addr
54 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
55 ; ATTRIBUTOR-NOT: nofree
56 ; ATTRIBUTOR-NEXT :define void @free_in_scc1(i8* nocapture) local_unnamed_addr
57 define void @free_in_scc1(i8* nocapture) local_unnamed_addr #0 {
53 ; FNATTR-NEXT: define void @free_in_scc1(i8* nocapture %0) local_unnamed_addr
54 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
55 ; ATTRIBUTOR-NOT: nofree
56 ; ATTRIBUTOR-NEXT :define void @free_in_scc1(i8* nocapture %0) local_unnamed_addr
57 define void @free_in_scc1(i8* nocapture %0) local_unnamed_addr #0 {
5858 tail call void @free_in_scc2(i8* %0) #1
5959 ret void
6060 }
6161
6262
6363 ; FNATTR: Function Attrs: noinline nounwind uwtable
64 ; FNATTR-NEXT: define void @free_in_scc2(i8* nocapture) local_unnamed_addr
65 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
66 ; ATTRIBUTOR-NOT: nofree
67 ; ATTRIBUTOR: define void @free_in_scc2(i8* nocapture) local_unnamed_addr
68 define void @free_in_scc2(i8* nocapture) local_unnamed_addr #0 {
64 ; FNATTR-NEXT: define void @free_in_scc2(i8* nocapture %0) local_unnamed_addr
65 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
66 ; ATTRIBUTOR-NOT: nofree
67 ; ATTRIBUTOR: define void @free_in_scc2(i8* nocapture %0) local_unnamed_addr
68 define void @free_in_scc2(i8* nocapture %0) local_unnamed_addr #0 {
6969 tail call void @free_in_scc1(i8* %0)
7070 tail call void @free(i8* %0) #1
7171 ret void
108108 ; }
109109
110110 ; FNATTR: Function Attrs: noinline nounwind uwtable
111 ; FNATTR-NEXT: define void @_Z9delete_opPc(i8*) local_unnamed_addr
112 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
113 ; ATTRIBUTOR-NOT: nofree
114 ; ATTRIBUTOR-NEXT: define void @_Z9delete_opPc(i8*) local_unnamed_addr #1
115 define void @_Z9delete_opPc(i8*) local_unnamed_addr #0 {
111 ; FNATTR-NEXT: define void @_Z9delete_opPc(i8* %0) local_unnamed_addr
112 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
113 ; ATTRIBUTOR-NOT: nofree
114 ; ATTRIBUTOR-NEXT: define void @_Z9delete_opPc(i8* %0) local_unnamed_addr #1
115 define void @_Z9delete_opPc(i8* %0) local_unnamed_addr #0 {
116116 %2 = icmp eq i8* %0, null
117117 br i1 %2, label %4, label %3
118118
128128 ; TEST 6 (negative case)
129129 ; Call realloc
130130 ; FNATTR: Function Attrs: noinline nounwind uwtable
131 ; FNATTR-NEXT: define noalias i8* @call_realloc(i8* nocapture, i64) local_unnamed_addr
132 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
133 ; ATTRIBUTOR-NOT: nofree
134 ; ATTRIBUTOR-NEXT: define noalias i8* @call_realloc(i8* nocapture, i64) local_unnamed_addr
135 define noalias i8* @call_realloc(i8* nocapture, i64) local_unnamed_addr #0 {
131 ; FNATTR-NEXT: define noalias i8* @call_realloc(i8* nocapture %0, i64 %1) local_unnamed_addr
132 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
133 ; ATTRIBUTOR-NOT: nofree
134 ; ATTRIBUTOR-NEXT: define noalias i8* @call_realloc(i8* nocapture %0, i64 %1) local_unnamed_addr
135 define noalias i8* @call_realloc(i8* nocapture %0, i64 %1) local_unnamed_addr #0 {
136136 %ret = tail call i8* @realloc(i8* %0, i64 %1) #2
137137 ret i8* %ret
138138 }
195195 ; TEST 10 (positive case)
196196 ; Call intrinsic function
197197 ; FNATTRS: Function Attrs: noinline readnone speculatable
198 ; FNATTRS-NEXT: declare float @llvm.floor.f32(float)
198 ; FNATTRS-NEXT: declare float @llvm.floor.f32(float %0)
199199 ; ATTRIBUTOR: Function Attrs: nounwind readnone speculatable
200200 ; ATTRIBUTOR-NEXT: declare float @llvm.floor.f32(float)
201201 declare float @llvm.floor.f32(float)
4242 ; }
4343
4444 ; FNATTR: Function Attrs: nofree norecurse nounwind uwtable
45 ; FNATTR-NEXT: define i32 @load_monotonic(i32* nocapture readonly)
45 ; FNATTR-NEXT: define i32 @load_monotonic(i32* nocapture readonly %0)
4646 ; ATTRIBUTOR: Function Attrs: nofree norecurse nosync nounwind uwtable
47 ; ATTRIBUTOR-NEXT: define i32 @load_monotonic(i32* nocapture readonly)
48 define i32 @load_monotonic(i32* nocapture readonly) norecurse nounwind uwtable {
47 ; ATTRIBUTOR-NEXT: define i32 @load_monotonic(i32* nocapture readonly %0)
48 define i32 @load_monotonic(i32* nocapture readonly %0) norecurse nounwind uwtable {
4949 %2 = load atomic i32, i32* %0 monotonic, align 4
5050 ret i32 %2
5151 }
5858 ; }
5959
6060 ; FNATTR: Function Attrs: nofree norecurse nounwind uwtable
61 ; FNATTR-NEXT: define void @store_monotonic(i32* nocapture)
61 ; FNATTR-NEXT: define void @store_monotonic(i32* nocapture %0)
6262 ; ATTRIBUTOR: Function Attrs: nofree norecurse nosync nounwind uwtable
63 ; ATTRIBUTOR-NEXT: define void @store_monotonic(i32* nocapture)
64 define void @store_monotonic(i32* nocapture) norecurse nounwind uwtable {
63 ; ATTRIBUTOR-NEXT: define void @store_monotonic(i32* nocapture %0)
64 define void @store_monotonic(i32* nocapture %0) norecurse nounwind uwtable {
6565 store atomic i32 10, i32* %0 monotonic, align 4
6666 ret void
6767 }
7474 ; }
7575
7676 ; FNATTR: Function Attrs: nofree norecurse nounwind uwtable
77 ; FNATTR-NEXT: define i32 @load_acquire(i32* nocapture readonly)
78 ; ATTRIBUTOR: Function Attrs: nofree norecurse nounwind uwtable
79 ; ATTRIBUTOR-NOT: nosync
80 ; ATTRIBUTOR-NEXT: define i32 @load_acquire(i32* nocapture readonly)
81 define i32 @load_acquire(i32* nocapture readonly) norecurse nounwind uwtable {
77 ; FNATTR-NEXT: define i32 @load_acquire(i32* nocapture readonly %0)
78 ; ATTRIBUTOR: Function Attrs: nofree norecurse nounwind uwtable
79 ; ATTRIBUTOR-NOT: nosync
80 ; ATTRIBUTOR-NEXT: define i32 @load_acquire(i32* nocapture readonly %0)
81 define i32 @load_acquire(i32* nocapture readonly %0) norecurse nounwind uwtable {
8282 %2 = load atomic i32, i32* %0 acquire, align 4
8383 ret i32 %2
8484 }
9090 ; }
9191
9292 ; FNATTR: Function Attrs: nofree norecurse nounwind uwtable
93 ; FNATTR-NEXT: define void @load_release(i32* nocapture)
94 ; ATTRIBUTOR: Function Attrs: nofree norecurse nounwind uwtable
95 ; ATTRIBUTOR-NOT: nosync
96 ; ATTRIBUTOR-NEXT: define void @load_release(i32* nocapture)
97 define void @load_release(i32* nocapture) norecurse nounwind uwtable {
93 ; FNATTR-NEXT: define void @load_release(i32* nocapture %0)
94 ; ATTRIBUTOR: Function Attrs: nofree norecurse nounwind uwtable
95 ; ATTRIBUTOR-NOT: nosync
96 ; ATTRIBUTOR-NEXT: define void @load_release(i32* nocapture %0)
97 define void @load_release(i32* nocapture %0) norecurse nounwind uwtable {
9898 store atomic volatile i32 10, i32* %0 release, align 4
9999 ret void
100100 }
102102 ; TEST 6 - negative volatile, relaxed atomic
103103
104104 ; FNATTR: Function Attrs: nofree norecurse nounwind uwtable
105 ; FNATTR-NEXT: define void @load_volatile_release(i32* nocapture)
106 ; ATTRIBUTOR: Function Attrs: nofree norecurse nounwind uwtable
107 ; ATTRIBUTOR-NOT: nosync
108 ; ATTRIBUTOR-NEXT: define void @load_volatile_release(i32* nocapture)
109 define void @load_volatile_release(i32* nocapture) norecurse nounwind uwtable {
105 ; FNATTR-NEXT: define void @load_volatile_release(i32* nocapture %0)
106 ; ATTRIBUTOR: Function Attrs: nofree norecurse nounwind uwtable
107 ; ATTRIBUTOR-NOT: nosync
108 ; ATTRIBUTOR-NEXT: define void @load_volatile_release(i32* nocapture %0)
109 define void @load_volatile_release(i32* nocapture %0) norecurse nounwind uwtable {
110110 store atomic volatile i32 10, i32* %0 release, align 4
111111 ret void
112112 }
118118 ; }
119119
120120 ; FNATTR: Function Attrs: nofree norecurse nounwind uwtable
121 ; FNATTR-NEXT: define void @volatile_store(i32*)
122 ; ATTRIBUTOR: Function Attrs: nofree norecurse nounwind uwtable
123 ; ATTRIBUTOR-NOT: nosync
124 ; ATTRIBUTOR-NEXT: define void @volatile_store(i32*)
125 define void @volatile_store(i32*) norecurse nounwind uwtable {
121 ; FNATTR-NEXT: define void @volatile_store(i32* %0)
122 ; ATTRIBUTOR: Function Attrs: nofree norecurse nounwind uwtable
123 ; ATTRIBUTOR-NOT: nosync
124 ; ATTRIBUTOR-NEXT: define void @volatile_store(i32* %0)
125 define void @volatile_store(i32* %0) norecurse nounwind uwtable {
126126 store volatile i32 14, i32* %0, align 4
127127 ret void
128128 }
135135 ; }
136136
137137 ; FNATTR: Function Attrs: nofree norecurse nounwind uwtable
138 ; FNATTR-NEXT: define i32 @volatile_load(i32*)
139 ; ATTRIBUTOR: Function Attrs: nofree norecurse nounwind uwtable
140 ; ATTRIBUTOR-NOT: nosync
141 ; ATTRIBUTOR-NEXT: define i32 @volatile_load(i32*)
142 define i32 @volatile_load(i32*) norecurse nounwind uwtable {
138 ; FNATTR-NEXT: define i32 @volatile_load(i32* %0)
139 ; ATTRIBUTOR: Function Attrs: nofree norecurse nounwind uwtable
140 ; ATTRIBUTOR-NOT: nosync
141 ; ATTRIBUTOR-NEXT: define i32 @volatile_load(i32* %0)
142 define i32 @volatile_load(i32* %0) norecurse nounwind uwtable {
143143 %2 = load volatile i32, i32* %0, align 4
144144 ret i32 %2
145145 }
183183 ; volatile operation in same scc. Call volatile_load defined in TEST 8.
184184
185185 ; FNATTR: Function Attrs: nofree noinline nounwind uwtable
186 ; FNATTR-NEXT: define i32 @scc1(i32*)
186 ; FNATTR-NEXT: define i32 @scc1(i32* %0)
187187 ; ATTRIBUTOR: Function Attrs: nofree noinline nounwind uwtable
188188 ; ATTRIBUTOR-NOT: nosync
189 ; ATTRIBUTOR-NEXT: define i32 @scc1(i32*)
190 define i32 @scc1(i32*) noinline nounwind uwtable {
189 ; ATTRIBUTOR-NEXT: define i32 @scc1(i32* %0)
190 define i32 @scc1(i32* %0) noinline nounwind uwtable {
191191 tail call void @scc2(i32* %0);
192192 %val = tail call i32 @volatile_load(i32* %0);
193193 ret i32 %val;
194194 }
195195
196196 ; FNATTR: Function Attrs: nofree noinline nounwind uwtable
197 ; FNATTR-NEXT: define void @scc2(i32*)
197 ; FNATTR-NEXT: define void @scc2(i32* %0)
198198 ; ATTRIBUTOR: Function Attrs: nofree noinline nounwind uwtable
199199 ; ATTRIBUTOR-NOT: nosync
200 ; ATTRIBUTOR-NEXT: define void @scc2(i32*)
201 define void @scc2(i32*) noinline nounwind uwtable {
200 ; ATTRIBUTOR-NEXT: define void @scc2(i32* %0)
201 define void @scc2(i32* %0) noinline nounwind uwtable {
202202 tail call i32 @scc1(i32* %0);
203203 ret void;
204204 }
223223 %"struct.std::__atomic_base" = type { i8 }
224224
225225 ; FNATTR: Function Attrs: nofree norecurse nounwind
226 ; FNATTR-NEXT: define void @foo1(i32* nocapture, %"struct.std::atomic"* nocapture)
227 ; ATTRIBUTOR-NOT: nosync
228 ; ATTRIBUTOR: define void @foo1(i32*, %"struct.std::atomic"*)
229 define void @foo1(i32*, %"struct.std::atomic"*) {
226 ; FNATTR-NEXT: define void @foo1(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
227 ; ATTRIBUTOR-NOT: nosync
228 ; ATTRIBUTOR: define void @foo1(i32* %0, %"struct.std::atomic"* %1)
229 define void @foo1(i32* %0, %"struct.std::atomic"* %1) {
230230 store i32 100, i32* %0, align 4
231231 fence release
232232 %3 = getelementptr inbounds %"struct.std::atomic", %"struct.std::atomic"* %1, i64 0, i32 0, i32 0
235235 }
236236
237237 ; FNATTR: Function Attrs: nofree norecurse nounwind
238 ; FNATTR-NEXT: define void @bar(i32* nocapture readnone, %"struct.std::atomic"* nocapture readonly)
239 ; ATTRIBUTOR-NOT: nosync
240 ; ATTRIBUTOR: define void @bar(i32*, %"struct.std::atomic"*)
241 define void @bar(i32 *, %"struct.std::atomic"*) {
238 ; FNATTR-NEXT: define void @bar(i32* nocapture readnone %0, %"struct.std::atomic"* nocapture readonly %1)
239 ; ATTRIBUTOR-NOT: nosync
240 ; ATTRIBUTOR: define void @bar(i32* %0, %"struct.std::atomic"* %1)
241 define void @bar(i32* %0, %"struct.std::atomic"* %1) {
242242 %3 = getelementptr inbounds %"struct.std::atomic", %"struct.std::atomic"* %1, i64 0, i32 0, i32 0
243243 br label %4
244244
255255
256256 ; TEST 13 - Fence syncscope("singlethread") seq_cst
257257 ; FNATTR: Function Attrs: nofree norecurse nounwind
258 ; FNATTR-NEXT: define void @foo1_singlethread(i32* nocapture, %"struct.std::atomic"* nocapture)
258 ; FNATTR-NEXT: define void @foo1_singlethread(i32* nocapture %0, %"struct.std::atomic"* nocapture %1)
259259 ; ATTRIBUTOR: Function Attrs: nofree nosync
260 ; ATTRIBUTOR: define void @foo1_singlethread(i32*, %"struct.std::atomic"*)
261 define void @foo1_singlethread(i32*, %"struct.std::atomic"*) {
260 ; ATTRIBUTOR: define void @foo1_singlethread(i32* %0, %"struct.std::atomic"* %1)
261 define void @foo1_singlethread(i32* %0, %"struct.std::atomic"* %1) {
262262 store i32 100, i32* %0, align 4
263263 fence syncscope("singlethread") release
264264 %3 = getelementptr inbounds %"struct.std::atomic", %"struct.std::atomic"* %1, i64 0, i32 0, i32 0
267267 }
268268
269269 ; FNATTR: Function Attrs: nofree norecurse nounwind
270 ; FNATTR-NEXT: define void @bar_singlethread(i32* nocapture readnone, %"struct.std::atomic"* nocapture readonly)
270 ; FNATTR-NEXT: define void @bar_singlethread(i32* nocapture readnone %0, %"struct.std::atomic"* nocapture readonly %1)
271271 ; ATTRIBUTOR: Function Attrs: nofree nosync
272 ; ATTRIBUTOR: define void @bar_singlethread(i32*, %"struct.std::atomic"*)
273 define void @bar_singlethread(i32 *, %"struct.std::atomic"*) {
272 ; ATTRIBUTOR: define void @bar_singlethread(i32* %0, %"struct.std::atomic"* %1)
273 define void @bar_singlethread(i32* %0, %"struct.std::atomic"* %1) {
274274 %3 = getelementptr inbounds %"struct.std::atomic", %"struct.std::atomic"* %1, i64 0, i32 0, i32 0
275275 br label %4
276276
4949 ; return -1;
5050 ; }
5151
52 ; CHECK: define i32 @maybe_throw(i1 zeroext)
53 ; ATTRIBUTOR: define i32 @maybe_throw(i1 zeroext)
54 define i32 @maybe_throw(i1 zeroext) {
52 ; CHECK: define i32 @maybe_throw(i1 zeroext %0)
53 ; ATTRIBUTOR: define i32 @maybe_throw(i1 zeroext %0)
54 define i32 @maybe_throw(i1 zeroext %0) {
5555 br i1 %0, label %2, label %3
5656
5757 2: ; preds = %1
0 ; RUN: opt < %s -functionattrs -S | FileCheck %s
11 ; RUN: opt < %s -passes=function-attrs -S | FileCheck %s
22
3 ; CHECK: define void @bar(i8* nocapture readnone)
4 define void @bar(i8* readonly) {
3 ; CHECK: define void @bar(i8* nocapture readnone %0)
4 define void @bar(i8* readonly %0) {
55 call void @foo(i8* %0)
66 ret void
77 }
88
9 ; CHECK: define void @foo(i8* nocapture readnone)
10 define void @foo(i8* readonly) {
9 ; CHECK: define void @foo(i8* nocapture readnone %0)
10 define void @foo(i8* readonly %0) {
1111 call void @bar(i8* %0)
1212 ret void
1313 }
2525 ; }
2626
2727 ; FNATTR: Function Attrs: noinline nounwind readnone uwtable
28 ; FNATTR-NEXT: define i32 @fib(i32)
29 ; FIXME: missing willreturn
30 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
31 ; ATTRIBUTOR-NEXT: define i32 @fib(i32) local_unnamed_addr
32 define i32 @fib(i32) local_unnamed_addr #0 {
28 ; FNATTR-NEXT: define i32 @fib(i32 %0)
29 ; FIXME: missing willreturn
30 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
31 ; ATTRIBUTOR-NEXT: define i32 @fib(i32 %0) local_unnamed_addr
32 define i32 @fib(i32 %0) local_unnamed_addr #0 {
3333 %2 = icmp slt i32 %0, 2
3434 br i1 %2, label %9, label %3
3535
5757
5858 ; FNATTR: Function Attrs: noinline norecurse nounwind readnone uwtable
5959 ; FNATTR-NOT: willreturn
60 ; FNATTR-NEXT: define i32 @fact_maybe_not_halt(i32) local_unnamed_addr
61 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
62 ; ATTRIBUTOR-NOT: willreturn
63 ; ATTRIBUTOR-NEXT: define i32 @fact_maybe_not_halt(i32) local_unnamed_addr
64 define i32 @fact_maybe_not_halt(i32) local_unnamed_addr #0 {
60 ; FNATTR-NEXT: define i32 @fact_maybe_not_halt(i32 %0) local_unnamed_addr
61 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
62 ; ATTRIBUTOR-NOT: willreturn
63 ; ATTRIBUTOR-NEXT: define i32 @fact_maybe_not_halt(i32 %0) local_unnamed_addr
64 define i32 @fact_maybe_not_halt(i32 %0) local_unnamed_addr #0 {
6565 %2 = icmp eq i32 %0, 0
6666 br i1 %2, label %11, label %3
6767
9393
9494 ; FIXME: missing willreturn
9595 ; FNATTR: Function Attrs: noinline norecurse nounwind readnone uwtable
96 ; FNATTR-NEXT: define i32 @fact_loop(i32)
97 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
98 ; ATTRIBUTOR-NEXT: define i32 @fact_loop(i32) local_unnamed_addr
99 define i32 @fact_loop(i32) local_unnamed_addr #0 {
96 ; FNATTR-NEXT: define i32 @fact_loop(i32 %0)
97 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
98 ; ATTRIBUTOR-NEXT: define i32 @fact_loop(i32 %0) local_unnamed_addr
99 define i32 @fact_loop(i32 %0) local_unnamed_addr #0 {
100100 %2 = icmp slt i32 %0, 1
101101 br i1 %2, label %3, label %5
102102
152152 ; FNATTR-NEXT: declare void @exit(i32) local_unnamed_addr
153153 ; ATTRIBUTOR: Function Attrs: noreturn
154154 ; ATTRIBUTOR-NEXT: declare void @exit(i32) local_unnamed_add
155 declare void @exit(i32) local_unnamed_addr noreturn
155 declare void @exit(i32 %0) local_unnamed_addr noreturn
156156
157157 ; FNATTR: Function Attrs: noinline nounwind uwtable
158158 ; FNATTR-NOT: willreturn
177177 ; }
178178 ; FNATTR: Function Attrs: noinline nounwind uwtable
179179 ; FNATTR-NOT: willreturn
180 ; FNATTR-NEXT: define void @conditional_exit(i32, i32* nocapture readonly) local_unnamed_addr
181 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
182 ; ATTRIBUTOR-NOT: willreturn
183 ; ATTRIBUTOR-NEXT: define void @conditional_exit(i32, i32* nocapture readonly) local_unnamed_addr
184 define void @conditional_exit(i32, i32* nocapture readonly) local_unnamed_addr #0 {
180 ; FNATTR-NEXT: define void @conditional_exit(i32 %0, i32* nocapture readonly %1) local_unnamed_addr
181 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
182 ; ATTRIBUTOR-NOT: willreturn
183 ; ATTRIBUTOR-NEXT: define void @conditional_exit(i32 %0, i32* nocapture readonly %1) local_unnamed_addr
184 define void @conditional_exit(i32 %0, i32* nocapture readonly %1) local_unnamed_addr #0 {
185185 %3 = icmp eq i32 %0, 0
186186 br i1 %3, label %5, label %4
187187
206206 ; Call intrinsic function
207207 ; FIXME: missing willreturn
208208 ; FNATTRS: Function Attrs: noinline readnone speculatable
209 ; FNATTRS-NEXT: declare float @llvm.floor.f32(float)
209 ; FNATTRS-NEXT: declare float @llvm.floor.f32(float %0)
210210 ; ATTRIBUTOR: Function Attrs: nounwind readnone speculatable
211211 ; ATTRIBUTOR-NEXT: declare float @llvm.floor.f32(float)
212212 declare float @llvm.floor.f32(float)
334334
335335 ; FIXME: missing willreturn
336336 ; FNATTR: Function Attrs: noinline norecurse nounwind readonly uwtable
337 ; FNATTR-NEXT: define i32 @loop_constant_trip_count(i32* nocapture readonly)
338 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
339 ; ATTRIBUTOR-NEXT: define i32 @loop_constant_trip_count(i32* nocapture readonly)
340 define i32 @loop_constant_trip_count(i32* nocapture readonly) #0 {
337 ; FNATTR-NEXT: define i32 @loop_constant_trip_count(i32* nocapture readonly %0)
338 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
339 ; ATTRIBUTOR-NEXT: define i32 @loop_constant_trip_count(i32* nocapture readonly %0)
340 define i32 @loop_constant_trip_count(i32* nocapture readonly %0) #0 {
341341 br label %3
342342
343343 ;
367367 ; }
368368 ; FNATTR: Function Attrs: noinline norecurse nounwind readonly uwtable
369369 ; FNATTR-NOT: willreturn
370 ; FNATTR-NEXT: define i32 @loop_trip_count_unbound(i32, i32, i32* nocapture readonly, i32) local_unnamed_addr
371 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
372 ; ATTRIBUTOR-NOT: willreturn
373 ; ATTRIBUTOR-NEXT: define i32 @loop_trip_count_unbound(i32, i32, i32* nocapture readonly, i32) local_unnamed_addr
374 define i32 @loop_trip_count_unbound(i32, i32, i32* nocapture readonly, i32) local_unnamed_addr #0 {
370 ; FNATTR-NEXT: define i32 @loop_trip_count_unbound(i32 %0, i32 %1, i32* nocapture readonly %2, i32 %3) local_unnamed_addr
371 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
372 ; ATTRIBUTOR-NOT: willreturn
373 ; ATTRIBUTOR-NEXT: define i32 @loop_trip_count_unbound(i32 %0, i32 %1, i32* nocapture readonly %2, i32 %3) local_unnamed_addr
374 define i32 @loop_trip_count_unbound(i32 %0, i32 %1, i32* nocapture readonly %2, i32 %3) local_unnamed_addr #0 {
375375 %5 = icmp eq i32 %0, %1
376376 br i1 %5, label %6, label %8
377377
405405
406406 ; FIXME: missing willreturn
407407 ; FNATTR: Function Attrs: noinline norecurse nounwind readonly uwtable
408 ; FNATTR-NEXT: define i32 @loop_trip_dec(i32, i32* nocapture readonly)
409 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
410 ; ATTRIBUTOR-NEXT: define i32 @loop_trip_dec(i32, i32* nocapture readonly) local_unnamed_addr
411
412 define i32 @loop_trip_dec(i32, i32* nocapture readonly) local_unnamed_addr #0 {
408 ; FNATTR-NEXT: define i32 @loop_trip_dec(i32 %0, i32* nocapture readonly %1)
409 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
410 ; ATTRIBUTOR-NEXT: define i32 @loop_trip_dec(i32 %0, i32* nocapture readonly %1) local_unnamed_addr
411
412 define i32 @loop_trip_dec(i32 %0, i32* nocapture readonly %1) local_unnamed_addr #0 {
413413 %3 = icmp sgt i32 %0, -1
414414 br i1 %3, label %4, label %14
415415
468468
469469 ; FIXME: missing willreturn
470470 ; FNATTR: Function Attrs: noinline nounwind uwtable
471 ; FNATTR-NEXT: define i32 @unreachable_exit_positive2(i32)
472 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
473 ; ATTRIBUTOR-NEXT: define i32 @unreachable_exit_positive2(i32)
471 ; FNATTR-NEXT: define i32 @unreachable_exit_positive2(i32 %0)
472 ; ATTRIBUTOR: Function Attrs: nofree noinline nosync nounwind uwtable
473 ; ATTRIBUTOR-NEXT: define i32 @unreachable_exit_positive2(i32 %0)
474474 define i32 @unreachable_exit_positive2(i32) local_unnamed_addr #0 {
475475 %2 = icmp slt i32 %0, 1
476476 br i1 %2, label %3, label %5
537537
538538 ; FNATTR: Function Attrs: noinline nounwind uwtable
539539 ; FNATTR-NOT: willreturn
540 ; FNATTR-NEXT: define void @call_longjmp(i8* nocapture readnone) local_unnamed_addr #3 {
541 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
542 ; ATTRIBUTOR-NOT: willreturn
543 ; ATTRIBUTOR-NEXT: define void @call_longjmp(i8* nocapture readnone) local_unnamed_addr
544 define void @call_longjmp(i8* nocapture readnone) local_unnamed_addr #0 {
540 ; FNATTR-NEXT: define void @call_longjmp(i8* nocapture readnone %0) local_unnamed_addr #3 {
541 ; ATTRIBUTOR: Function Attrs: noinline nounwind uwtable
542 ; ATTRIBUTOR-NOT: willreturn
543 ; ATTRIBUTOR-NEXT: define void @call_longjmp(i8* nocapture readnone %0) local_unnamed_addr
544 define void @call_longjmp(i8* nocapture readnone %0) local_unnamed_addr #0 {
545545 tail call void @llvm.eh.sjlj.longjmp(i8* %0)
546546 ret void
547547 }
1717 unreachable
1818 }
1919
20 ; CHECK: define internal i32 @foo(i32*)
20 ; CHECK: define internal i32 @foo(i32* %0)
2121
2222 attributes #0 = { naked }
495495 ; merge fully redudant and then we can jump-thread the block with the
496496 ; store.
497497 ;
498 ; CHECK-LABEL: define i32 @phi_translate_partial_redundant_loads(i32, i32*, i32*
498 ; CHECK-LABEL: define i32 @phi_translate_partial_redundant_loads(i32 %0, i32* %1, i32* %2
499499 ; CHECK: merge.thread:
500500 ; CHECK: store
501501 ; CHECK: br label %left_x
125125 ret { i32*, i32 } %d
126126 }
127127
128 ; CHECK: define i32 @hoist_bitreverse(i32)
128 ; CHECK: define i32 @hoist_bitreverse(i32 %0)
129129 ; CHECK: bitreverse
130130 ; CHECK: br label %header
131 define i32 @hoist_bitreverse(i32) {
131 define i32 @hoist_bitreverse(i32 %0) {
132132 br label %header
133133
134134 header:
1919 }
2020
2121 ; CHECK-DAG: define linkonce_odr hidden i32 @f(i32 %x, i32 %y) comdat
22 ; CHECK-DAG: define linkonce_odr hidden i32 @g(i32, i32) comdat
22 ; CHECK-DAG: define linkonce_odr hidden i32 @g(i32 %0, i32 %1) comdat
2323
22 ; Ensure that we do not merge functions that are identical with the
33 ; exception of the order of the incoming blocks to a phi.
44
5 ; CHECK-LABEL: define linkonce_odr hidden i1 @first(i2)
6 define linkonce_odr hidden i1 @first(i2) {
5 ; CHECK-LABEL: define linkonce_odr hidden i1 @first(i2 %0)
6 define linkonce_odr hidden i1 @first(i2 %0) {
77 entry:
88 ; CHECK: switch i2
99 switch i2 %0, label %default [
2525 ret i1 %result
2626 }
2727
28 ; CHECK-LABEL: define linkonce_odr hidden i1 @second(i2)
29 define linkonce_odr hidden i1 @second(i2) {
28 ; CHECK-LABEL: define linkonce_odr hidden i1 @second(i2 %0)
29 define linkonce_odr hidden i1 @second(i2 %0) {
3030 entry:
3131 ; CHECK: switch i2
3232 switch i2 %0, label %default [
11
22 ; Weak functions too small for merging to be profitable
33
4 ; CHECK: define weak i32 @foo(i8*, i32)
4 ; CHECK: define weak i32 @foo(i8* %0, i32 %1)
55 ; CHECK-NEXT: ret i32 %1
6 ; CHECK: define weak i32 @bar(i8*, i32)
6 ; CHECK: define weak i32 @bar(i8* %0, i32 %1)
77 ; CHECK-NEXT: ret i32 %1
88
9 define weak i32 @foo(i8*, i32) #0 {
9 define weak i32 @foo(i8* %0, i32 %1) #0 {
1010 ret i32 %1
1111 }
1212
13 define weak i32 @bar(i8*, i32) #0 {
13 define weak i32 @bar(i8* %0, i32 %1) #0 {
1414 ret i32 %1
1515 }
147147 }
148148
149149 ; CHECK-LABEL: define internal void @branch_funnel(i8*
150 ; CHECK: define hidden void @__typeid_typeid1_0_branch_funnel(i8* nest, ...)
150 ; CHECK: define hidden void @__typeid_typeid1_0_branch_funnel(i8* nest %0, ...)
151151 ; CHECK-NEXT: musttail call void (...) @llvm.icall.branch.funnel(i8* %0, i8* bitcast ([1 x i8*]* {{(nonnull )?}}@vt1_1 to i8*), i32 (i8*, i32)* {{(nonnull )?}}@vf1_1, i8* bitcast ([1 x i8*]* {{(nonnull )?}}@vt1_2 to i8*), i32 (i8*, i32)* {{(nonnull )?}}@vf1_2, ...)
152152
153153 declare i1 @llvm.type.test(i8*, metadata)
7575 ; CHECK: declare void @vf1(i8*)
7676 declare void @vf1(i8*)
7777
78 ; CHECK: define void @vf2(i8*)
78 ; CHECK: define void @vf2(i8* %0)
7979 define void @vf2(i8*) {
8080 ret void
8181 }
8282
83 ; CHECK: define hidden void @"vf3$merged"(i8*) {
83 ; CHECK: define hidden void @"vf3$merged"(i8* %0) {
8484 define internal void @vf3(i8*) {
8585 ret void
8686 }
8787
88 ; CHECK: define hidden void @"vf4$merged"(i8*) comdat {
88 ; CHECK: define hidden void @"vf4$merged"(i8* %0) comdat {
8989 define internal void @vf4(i8*) comdat {
9090 ret void
9191 }
3434 EXPECT_TRUE(r != std::string::npos);
3535 }
3636
37 TEST(AsmWriterTest, DebugPrintDetachedArgument) {
38 LLVMContext Ctx;
39 auto Ty = Type::getInt32Ty(Ctx);
40 auto Arg = new Argument(Ty);
41
42 std::string S;
43 raw_string_ostream OS(S);
44 Arg->print(OS);
45 EXPECT_EQ(S, "i32 ");
46 }
47
3748 TEST(AsmWriterTest, DumpDIExpression) {
3849 LLVMContext Ctx;
3950 uint64_t Ops[] = {
0 #!/usr/bin/env python3
1 import re, sys
2
3 def fix_string(s):
4 TYPE = re.compile('\s*(i[0-9]+|float|double|x86_fp80|fp128|ppc_fp128|\[\[.*?\]\]|\[2 x \[\[[A-Z_0-9]+\]\]\]|<.*?>|{.*?}|\[[0-9]+ x .*?\]|%["a-z:A-Z0-9._]+({{.*?}})?|%{{.*?}}|{{.*?}}|\[\[.*?\]\])(\s*(\*|addrspace\(.*?\)|dereferenceable\(.*?\)|byval\(.*?\)|sret|zeroext|inreg|returned|signext|nocapture|align \d+|swiftself|swifterror|readonly|noalias|inalloca|nocapture))*\s*')
5
6 counter = 0
7 if 'i32{{.*}}' in s:
8 counter = 1
9
10 at_pos = s.find('@')
11 if at_pos == -1:
12 at_pos = 0
13
14 annoying_pos = s.find('{{[^(]+}}')
15 if annoying_pos != -1:
16 at_pos = annoying_pos + 9
17
18 paren_pos = s.find('(', at_pos)
19 if paren_pos == -1:
20 return s
21
22 res = s[:paren_pos+1]
23 s = s[paren_pos+1:]
24
25 m = TYPE.match(s)
26 while m:
27 res += m.group()
28 s = s[m.end():]
29 if s.startswith(',') or s.startswith(')'):
30 res += f' %{counter}'
31 counter += 1
32
33 next_arg = s.find(',')
34 if next_arg == -1:
35 break
36
37 res += s[:next_arg+1]
38 s = s[next_arg+1:]
39 m = TYPE.match(s)
40
41 return res+s
42
43 def process_file(contents):
44 PREFIX = re.compile(r'check-prefix(es)?(=|\s+)([a-zA-Z0-9,]+)')
45 check_prefixes = ['CHECK']
46 result = ''
47 for line in contents.split('\n'):
48 if 'FileCheck' in line:
49 m = PREFIX.search(line)
50 if m:
51 check_prefixes.extend(m.group(3).split(','))
52
53 found_check = False
54 for prefix in check_prefixes:
55 if prefix in line:
56 found_check = True
57 break
58
59 if not found_check or 'define' not in line:
60 result += line + '\n'
61 continue
62
63 # We have a check for a function definition. Number the args.
64 line = fix_string(line)
65 result += line + '\n'
66 return result
67
68 def main():
69 print(f'Processing {sys.argv[1]}')
70 f = open(sys.argv[1])
71 content = f.read()
72 f.close()
73
74 content = process_file(content)
75
76 f = open(sys.argv[1], 'w')
77 f.write(content)
78 f.close()
79
80 if __name__ == '__main__':
81 main()