llvm.org GIT mirror llvm / c4a8c07
Change objectsize intrinsic to accept different address spaces. Bitcasting everything to i8* won't work. Autoupgrade the old intrinsic declarations to use the new mangling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192117 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 6 years ago
13 changed file(s) with 167 addition(s) and 50 deletion(s). Raw diff Collapse all Expand all
327327 def int_siglongjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>;
328328
329329 // Internal interface for object size checking
330 def int_objectsize : Intrinsic<[llvm_anyint_ty], [llvm_ptr_ty, llvm_i1_ty],
330 def int_objectsize : Intrinsic<[llvm_anyint_ty], [llvm_anyptr_ty, llvm_i1_ty],
331331 [IntrNoMem]>,
332332 GCCBuiltin<"__builtin_object_size">;
333333
8787 }
8888 break;
8989 }
90 case 'o':
91 // We only need to change the name to match the mangling including the
92 // address space.
93 if (F->arg_size() == 2 && Name.startswith("objectsize.")) {
94 Type *Tys[2] = { F->getReturnType(), F->arg_begin()->getType() };
95 if (F->getName() != Intrinsic::getName(Intrinsic::objectsize, Tys)) {
96 F->setName(Name + ".old");
97 NewFn = Intrinsic::getDeclaration(F->getParent(),
98 Intrinsic::objectsize, Tys);
99 return true;
100 }
101 }
102 break;
103
90104 case 'x': {
91105 if (Name.startswith("x86.sse2.pcmpeq.") ||
92106 Name.startswith("x86.sse2.pcmpgt.") ||
316330 CI->eraseFromParent();
317331 return;
318332
333 case Intrinsic::objectsize:
334 CI->replaceAllUsesWith(Builder.CreateCall2(NewFn,
335 CI->getArgOperand(0),
336 CI->getArgOperand(1),
337 Name));
338 CI->eraseFromParent();
339 return;
340
319341 case Intrinsic::arm_neon_vclz: {
320342 // Change name from llvm.arm.neon.vclz.* to llvm.ctlz.*
321343 CI->replaceAllUsesWith(Builder.CreateCall2(NewFn, CI->getArgOperand(0),
44 declare i16 @llvm.ctlz.i16(i16)
55 declare i32 @llvm.ctlz.i32(i32)
66 declare i42 @llvm.ctlz.i42(i42) ; Not a power-of-2
7
8
9 declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly
10
711
812 define void @test.ctlz(i8 %a, i16 %b, i32 %c, i42 %d) {
913 ; CHECK: @test.ctlz
4145
4246 ret void
4347 }
48
49
50 @a = private global [60 x i8] zeroinitializer, align 1
51
52 define i32 @test.objectsize() {
53 ; CHECK-LABEL: @test.objectsize(
54 ; CHECK: @llvm.objectsize.i32.p0i8
55 ; CHECK-DAG: declare i32 @llvm.objectsize.i32.p0i8
56 %s = call i32 @llvm.objectsize.i32(i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0), i1 false)
57 ret i32 %s
58 }
5959 %3 = load i32* @tabsize, align 4
6060 %4 = srem i32 %cols, %3
6161 %5 = sdiv i32 %cols, %3
62 %6 = tail call i32 @llvm.objectsize.i32(i8* null, i1 false)
62 %6 = tail call i32 @llvm.objectsize.i32.p0i8(i8* null, i1 false)
6363 %7 = tail call i8* @__memset_chk(i8* null, i32 9, i32 %5, i32 %6) nounwind
6464 br label %bb1
6565
7070 ret void
7171 }
7272
73 declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readnone
73 declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readnone
7474 declare i8* @__memset_chk(i8*, i32, i32, i32) nounwind
7575
7676 ; rdar://11714607
2222 %3 = load double* %1, align 4
2323 %4 = load double* %0, align 4
2424 call void @Parse_Vector(double* %0) nounwind
25 %5 = call i32 @llvm.objectsize.i32(i8* undef, i1 false)
25 %5 = call i32 @llvm.objectsize.i32.p0i8(i8* undef, i1 false)
2626 %6 = icmp eq i32 %5, -1
2727 br i1 %6, label %bb34, label %bb33
2828
3535 }
3636
3737 declare void @Parse_Vector(double*)
38 declare i32 @llvm.objectsize.i32(i8*, i1)
38 declare i32 @llvm.objectsize.i32.p0i8(i8*, i1)
3939
4040
4141 ; PR9578
77
88 @aux_temp = external global %struct.dfa, align 8
99
10 declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readnone
10 declare i64 @llvm.objectsize.i64.p0i8(i8*, i1) nounwind readnone
1111
1212 declare void @__memset_chk() nounwind
1313
2020 br i1 undef, label %land.end.thread.i, label %land.end.i
2121
2222 land.end.thread.i: ; preds = %if.end.i
23 %0 = call i64 @llvm.objectsize.i64(i8* undef, i1 false) nounwind
23 %0 = call i64 @llvm.objectsize.i64.p0i8(i8* undef, i1 false) nounwind
2424 %cmp1710.i = icmp eq i64 %0, -1
2525 br i1 %cmp1710.i, label %cond.false156.i, label %cond.true138.i
2626
2727 land.end.i: ; preds = %if.end.i
28 %1 = call i64 @llvm.objectsize.i64(i8* undef, i1 false) nounwind
28 %1 = call i64 @llvm.objectsize.i64.p0i8(i8* undef, i1 false) nounwind
2929 %cmp17.i = icmp eq i64 %1, -1
3030 br i1 %cmp17.i, label %cond.false156.i, label %cond.true138.i
3131
203203 ;
204204 define fastcc void @func_61() nounwind sspreq {
205205 entry:
206 %t1 = tail call i64 @llvm.objectsize.i64(i8* undef, i1 false)
206 %t1 = tail call i64 @llvm.objectsize.i64.p0i8(i8* undef, i1 false)
207207 %t2 = icmp eq i64 %t1, -1
208208 br i1 %t2, label %bb2, label %bb1
209209
214214 ret void
215215 }
216216
217 declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readnone
217 declare i64 @llvm.objectsize.i64.p0i8(i8*, i1) nounwind readnone
218218
219219 ; PR10277
220220 ; This test has dead code elimination caused by remat during spilling.
99 define void @bar() nounwind ssp {
1010 entry:
1111 %tmp = load i8** @p ; [#uses=1]
12 %0 = call i64 @llvm.objectsize.i64(i8* %tmp, i1 0) ; [#uses=1]
12 %0 = call i64 @llvm.objectsize.i64.p0i8(i8* %tmp, i1 0) ; [#uses=1]
1313 %cmp = icmp ne i64 %0, -1 ; [#uses=1]
1414 ; X64: movabsq $-1, [[RAX:%r..]]
1515 ; X64: cmpq $-1, [[RAX]]
1818 cond.true: ; preds = %entry
1919 %tmp1 = load i8** @p ; [#uses=1]
2020 %tmp2 = load i8** @p ; [#uses=1]
21 %1 = call i64 @llvm.objectsize.i64(i8* %tmp2, i1 1) ; [#uses=1]
21 %1 = call i64 @llvm.objectsize.i64.p0i8(i8* %tmp2, i1 1) ; [#uses=1]
2222 %call = call i8* @__strcpy_chk(i8* %tmp1, i8* getelementptr inbounds ([3 x i8]* @.str, i32 0, i32 0), i64 %1) ssp ; [#uses=1]
2323 br label %cond.end
2424
3232 ret void
3333 }
3434
35 declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readonly
35 declare i64 @llvm.objectsize.i64.p0i8(i8*, i1) nounwind readonly
3636
3737 declare i8* @__strcpy_chk(i8*, i8*, i64) ssp
3838
4646 %tmp = load i8** %__dest.addr ; [#uses=1]
4747 %tmp1 = load i8** %__src.addr ; [#uses=1]
4848 %tmp2 = load i8** %__dest.addr ; [#uses=1]
49 %0 = call i64 @llvm.objectsize.i64(i8* %tmp2, i1 1) ; [#uses=1]
49 %0 = call i64 @llvm.objectsize.i64.p0i8(i8* %tmp2, i1 1) ; [#uses=1]
5050 %call = call i8* @__strcpy_chk(i8* %tmp, i8* %tmp1, i64 %0) ssp ; [#uses=1]
5151 store i8* %call, i8** %retval
5252 %1 = load i8** %retval ; [#uses=1]
11
22 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
33
4 declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readnone
4 declare i64 @llvm.objectsize.i64.p0i8(i8*, i1) nounwind readnone
55
66 declare i8* @foo(i8*, i32, i64, i64) nounwind
77
2222 %tmp1 = load i32* %__val.addr, align 4, !dbg !21
2323 %tmp2 = load i64* %__len.addr, align 8, !dbg !21
2424 %tmp3 = load i8** %__dest.addr, align 8, !dbg !21
25 %0 = call i64 @llvm.objectsize.i64(i8* %tmp3, i1 false), !dbg !21
25 %0 = call i64 @llvm.objectsize.i64.p0i8(i8* %tmp3, i1 false), !dbg !21
2626 %call = call i8* @foo(i8* %tmp, i32 %tmp1, i64 %tmp2, i64 %0), !dbg !21
2727 ret i8* %call, !dbg !21
2828 }
0 ; RUN: opt -S -instcombine -o - %s | FileCheck %s
1 target datalayout = "e-p:32:32:32-p1:64:64:64-p2:8:8:8-p3:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32"
2
3 declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readonly
4 declare i32 @llvm.objectsize.i32.p1i8(i8 addrspace(1)*, i1) nounwind readonly
5 declare i32 @llvm.objectsize.i32.p2i8(i8 addrspace(2)*, i1) nounwind readonly
6 declare i32 @llvm.objectsize.i32.p3i8(i8 addrspace(3)*, i1) nounwind readonly
7 declare i16 @llvm.objectsize.i16.p3i8(i8 addrspace(3)*, i1) nounwind readonly
8
9 @array_as2 = private addrspace(2) global [60 x i8] zeroinitializer, align 4
10
11 @array_as1_pointers = private global [10 x i32 addrspace(1)*] zeroinitializer, align 4
12 @array_as2_pointers = private global [24 x i32 addrspace(2)*] zeroinitializer, align 4
13 @array_as3_pointers = private global [42 x i32 addrspace(3)*] zeroinitializer, align 4
14
15 @array_as2_as1_pointer_pointers = private global [16 x i32 addrspace(2)* addrspace(1)*] zeroinitializer, align 4
16
17
18 @a_as3 = private addrspace(3) global [60 x i8] zeroinitializer, align 1
19
20 define i32 @foo_as3() nounwind {
21 ; CHECK-LABEL: @foo_as3(
22 ; CHECK-NEXT: ret i32 60
23 %1 = call i32 @llvm.objectsize.i32.p3i8(i8 addrspace(3)* getelementptr inbounds ([60 x i8] addrspace(3)* @a_as3, i32 0, i32 0), i1 false)
24 ret i32 %1
25 }
26
27 define i16 @foo_as3_i16() nounwind {
28 ; CHECK-LABEL: @foo_as3_i16(
29 ; CHECK-NEXT: ret i16 60
30 %1 = call i16 @llvm.objectsize.i16.p3i8(i8 addrspace(3)* getelementptr inbounds ([60 x i8] addrspace(3)* @a_as3, i32 0, i32 0), i1 false)
31 ret i16 %1
32 }
33
34 @a_alias = alias weak [60 x i8] addrspace(3)* @a_as3
35 define i32 @foo_alias() nounwind {
36 %1 = call i32 @llvm.objectsize.i32.p3i8(i8 addrspace(3)* getelementptr inbounds ([60 x i8] addrspace(3)* @a_alias, i32 0, i32 0), i1 false)
37 ret i32 %1
38 }
39
40 define i32 @array_as2_size() {
41 ; CHECK-LABEL: @array_as2_size(
42 ; CHECK-NEXT: ret i32 60
43 %bc = bitcast [60 x i8] addrspace(2)* @array_as2 to i8 addrspace(2)*
44 %1 = call i32 @llvm.objectsize.i32.p2i8(i8 addrspace(2)* %bc, i1 false)
45 ret i32 %1
46 }
47
48 define i32 @pointer_array_as1() {
49 ; CHECK-LABEL: @pointer_array_as1(
50 ; CHECK-NEXT: ret i32 80
51 %bc = bitcast [10 x i32 addrspace(1)*]* @array_as1_pointers to i8 addrspace(1)*
52 %1 = call i32 @llvm.objectsize.i32.p1i8(i8 addrspace(1)* %bc, i1 false)
53 ret i32 %1
54 }
55
56 define i32 @pointer_array_as2() {
57 ; CHECK-LABEL: @pointer_array_as2(
58 ; CHECK-NEXT: ret i32 24
59 %bc = bitcast [24 x i32 addrspace(2)*]* @array_as2_pointers to i8*
60 %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %bc, i1 false)
61 ret i32 %1
62 }
63
64 define i32 @pointer_array_as3() {
65 ; CHECK-LABEL: @pointer_array_as3(
66 ; CHECK-NEXT: ret i32 84
67 %bc = bitcast [42 x i32 addrspace(3)*]* @array_as3_pointers to i8*
68 %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %bc, i1 false)
69 ret i32 %1
70 }
71
72 define i32 @pointer_pointer_array_as2_as1() {
73 ; CHECK-LABEL: @pointer_pointer_array_as2_as1(
74 ; CHECK-NEXT: ret i32 128
75 %bc = bitcast [16 x i32 addrspace(2)* addrspace(1)*]* @array_as2_as1_pointer_pointers to i8*
76 %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %bc, i1 false)
77 ret i32 %1
78 }
79
44
55 @a = private global [60 x i8] zeroinitializer, align 1 ; <[60 x i8]*>
66 @.str = private constant [8 x i8] c"abcdefg\00" ; <[8 x i8]*>
7
87 define i32 @foo() nounwind {
98 ; CHECK-LABEL: @foo(
109 ; CHECK-NEXT: ret i32 60
11 %1 = call i32 @llvm.objectsize.i32(i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0), i1 false)
10 %1 = call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0), i1 false)
1211 ret i32 %1
1312 }
1413
1615 ; CHECK-LABEL: @bar(
1716 entry:
1817 %retval = alloca i8*
19 %0 = call i32 @llvm.objectsize.i32(i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0), i1 false)
18 %0 = call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0), i1 false)
2019 %cmp = icmp ne i32 %0, -1
2120 ; CHECK: br i1 true
2221 br i1 %cmp, label %cond.true, label %cond.false
3332 define i32 @f() nounwind {
3433 ; CHECK-LABEL: @f(
3534 ; CHECK-NEXT: ret i32 0
36 %1 = call i32 @llvm.objectsize.i32(i8* getelementptr ([60 x i8]* @a, i32 1, i32 0), i1 false)
35 %1 = call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr ([60 x i8]* @a, i32 1, i32 0), i1 false)
3736 ret i32 %1
3837 }
3938
4241 define i1 @baz() nounwind {
4342 ; CHECK-LABEL: @baz(
4443 ; CHECK-NEXT: objectsize
45 %1 = tail call i32 @llvm.objectsize.i32(i8* getelementptr inbounds ([0 x i8]* @window, i32 0, i32 0), i1 false)
44 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr inbounds ([0 x i8]* @window, i32 0, i32 0), i1 false)
4645 %2 = icmp eq i32 %1, -1
4746 ret i1 %2
4847 }
4948
5049 define void @test1(i8* %q, i32 %x) nounwind noinline {
5150 ; CHECK-LABEL: @test1(
52 ; CHECK: objectsize.i32
53 entry:
54 %0 = call i32 @llvm.objectsize.i32(i8* getelementptr inbounds ([0 x i8]* @window, i32 0, i32 10), i1 false) ; [#uses=1]
51 ; CHECK: objectsize.i32.p0i8
52 entry:
53 %0 = call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr inbounds ([0 x i8]* @window, i32 0, i32 10), i1 false) ; [#uses=1]
5554 %1 = icmp eq i32 %0, -1 ; [#uses=1]
5655 br i1 %1, label %"47", label %"46"
5756
6766 define i32 @test2() nounwind {
6867 ; CHECK-LABEL: @test2(
6968 ; CHECK-NEXT: ret i32 34
70 %1 = call i32 @llvm.objectsize.i32(i8* getelementptr (i8* bitcast ([9 x i32]* @.str5 to i8*), i32 2), i1 false)
69 %1 = call i32 @llvm.objectsize.i32.p0i8(i8* getelementptr (i8* bitcast ([9 x i32]* @.str5 to i8*), i32 2), i1 false)
7170 ret i32 %1
7271 }
7372
7675
7776 declare i8* @__memcpy_chk(i8*, i8*, i32, i32) nounwind
7877
79 declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly
78 declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readonly
8079
8180 declare i8* @__inline_memcpy_chk(i8*, i8*, i32) nounwind inlinehint
8281
8887 bb11:
8988 %0 = getelementptr inbounds float* getelementptr inbounds ([480 x float]* @array, i32 0, i32 128), i32 -127 ; [#uses=1]
9089 %1 = bitcast float* %0 to i8* ; [#uses=1]
91 %2 = call i32 @llvm.objectsize.i32(i8* %1, i1 false) ; [#uses=1]
90 %2 = call i32 @llvm.objectsize.i32.p0i8(i8* %1, i1 false) ; [#uses=1]
9291 %3 = call i8* @__memcpy_chk(i8* undef, i8* undef, i32 512, i32 %2) nounwind ; [#uses=0]
9392 ; CHECK: unreachable
9493 unreachable
110109 entry:
111110 %0 = alloca %struct.data, align 8
112111 %1 = bitcast %struct.data* %0 to i8*
113 %2 = call i32 @llvm.objectsize.i32(i8* %1, i1 false) nounwind
112 %2 = call i32 @llvm.objectsize.i32.p0i8(i8* %1, i1 false) nounwind
114113 ; CHECK-NOT: @llvm.objectsize
115114 ; CHECK: @llvm.memset.p0i8.i32(i8* %1, i8 0, i32 1824, i32 8, i1 false)
116115 %3 = call i8* @__memset_chk(i8* %1, i32 0, i32 1824, i32 %2) nounwind
125124 ; CHECK-LABEL: @test5(
126125 entry:
127126 %0 = tail call noalias i8* @malloc(i32 20) nounwind
128 %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false)
127 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %0, i1 false)
129128 %2 = load i8** @s, align 8
130129 ; CHECK-NOT: @llvm.objectsize
131130 ; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false)
137136 ; CHECK-LABEL: @test6(
138137 entry:
139138 %0 = tail call noalias i8* @malloc(i32 20) nounwind
140 %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false)
139 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %0, i1 false)
141140 %2 = load i8** @s, align 8
142141 ; CHECK-NOT: @llvm.objectsize
143142 ; CHECK: @__memcpy_chk(i8* %0, i8* %1, i32 30, i32 20)
154153 %alloc = call noalias i8* @malloc(i32 48) nounwind
155154 store i8* %alloc, i8** %esc
156155 %gep = getelementptr inbounds i8* %alloc, i32 16
157 %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false) nounwind readonly
156 %objsize = call i32 @llvm.objectsize.i32.p0i8(i8* %gep, i1 false) nounwind readonly
158157 ; CHECK: ret i32 32
159158 ret i32 %objsize
160159 }
166165 %alloc = call noalias i8* @calloc(i32 5, i32 7) nounwind
167166 store i8* %alloc, i8** %esc
168167 %gep = getelementptr inbounds i8* %alloc, i32 5
169 %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false) nounwind readonly
168 %objsize = call i32 @llvm.objectsize.i32.p0i8(i8* %gep, i1 false) nounwind readonly
170169 ; CHECK: ret i32 30
171170 ret i32 %objsize
172171 }
178177 define i32 @test9(i8** %esc) {
179178 %call = tail call i8* @strdup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0)) nounwind
180179 store i8* %call, i8** %esc, align 8
181 %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true)
180 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %call, i1 true)
182181 ; CHECK: ret i32 8
183182 ret i32 %1
184183 }
187186 define i32 @test10(i8** %esc) {
188187 %call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 3) nounwind
189188 store i8* %call, i8** %esc, align 8
190 %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true)
189 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %call, i1 true)
191190 ; CHECK: ret i32 4
192191 ret i32 %1
193192 }
196195 define i32 @test11(i8** %esc) {
197196 %call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 7) nounwind
198197 store i8* %call, i8** %esc, align 8
199 %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true)
198 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %call, i1 true)
200199 ; CHECK: ret i32 8
201200 ret i32 %1
202201 }
205204 define i32 @test12(i8** %esc) {
206205 %call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 8) nounwind
207206 store i8* %call, i8** %esc, align 8
208 %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true)
207 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %call, i1 true)
209208 ; CHECK: ret i32 8
210209 ret i32 %1
211210 }
214213 define i32 @test13(i8** %esc) {
215214 %call = tail call i8* @strndup(i8* getelementptr inbounds ([8 x i8]* @.str, i64 0, i64 0), i32 57) nounwind
216215 store i8* %call, i8** %esc, align 8
217 %1 = tail call i32 @llvm.objectsize.i32(i8* %call, i1 true)
216 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %call, i1 true)
218217 ; CHECK: ret i32 8
219218 ret i32 %1
220219 }
228227 xpto:
229228 %select = select i1 %bool, i8* %select, i8* %a
230229 %select2 = select i1 %bool, i8* %a, i8* %select2
231 %0 = tail call i32 @llvm.objectsize.i32(i8* %select, i1 true)
232 %1 = tail call i32 @llvm.objectsize.i32(i8* %select2, i1 true)
230 %0 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %select, i1 true)
231 %1 = tail call i32 @llvm.objectsize.i32.p0i8(i8* %select2, i1 true)
233232 %2 = add i32 %0, %1
234233 ; CHECK: ret i32 undef
235234 ret i32 %2
248247 xpto:
249248 %gep2 = getelementptr i8* %gep, i32 1
250249 %gep = getelementptr i8* %gep2, i32 1
251 %o = call i32 @llvm.objectsize.i32(i8* %gep, i1 true)
250 %o = call i32 @llvm.objectsize.i32.p0i8(i8* %gep, i1 true)
252251 ; CHECK: ret i32 undef
253252 ret i32 %o
254253
262261 ; CHECK-NEXT: ret i32 60
263262 define i32 @test18() {
264263 %bc = bitcast [60 x i8]* @globalalias to i8*
265 %1 = call i32 @llvm.objectsize.i32(i8* %bc, i1 false)
264 %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %bc, i1 false)
266265 ret i32 %1
267266 }
268267
272271 ; CHECK: llvm.objectsize
273272 define i32 @test19() {
274273 %bc = bitcast [60 x i8]* @globalalias2 to i8*
275 %1 = call i32 @llvm.objectsize.i32(i8* %bc, i1 false)
276 ret i32 %1
277 }
274 %1 = call i32 @llvm.objectsize.i32.p0i8(i8* %bc, i1 false)
275 ret i32 %1
276 }
277
6060 %src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
6161
6262 ; CHECK: @__memcpy_chk
63 %len = call i32 @llvm.objectsize.i32(i8* %dst, i1 false)
63 %len = call i32 @llvm.objectsize.i32.p0i8(i8* %dst, i1 false)
6464 %ret = call i8* @__stpcpy_chk(i8* %dst, i8* %src, i32 %len)
6565 ; CHECK: ret i8* getelementptr inbounds ([60 x i8]* @a, i32 0, i32 11)
6666 ret i8* %ret
7474
7575 ; CHECK: [[LEN:%[a-z]+]] = call i32 @strlen
7676 ; CHECK-NEXT: getelementptr inbounds [60 x i8]* @a, i32 0, i32 [[LEN]]
77 %len = call i32 @llvm.objectsize.i32(i8* %dst, i1 false)
77 %len = call i32 @llvm.objectsize.i32.p0i8(i8* %dst, i1 false)
7878 %ret = call i8* @__stpcpy_chk(i8* %dst, i8* %dst, i32 %len)
7979 ret i8* %ret
8080 }
9292 }
9393
9494 declare i8* @__stpcpy_chk(i8*, i8*, i32) nounwind
95 declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly
95 declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readonly
6060 %src = getelementptr inbounds [12 x i8]* @.str, i32 0, i32 0
6161
6262 ; CHECK: @__memcpy_chk
63 %len = call i32 @llvm.objectsize.i32(i8* %dst, i1 false)
63 %len = call i32 @llvm.objectsize.i32.p0i8(i8* %dst, i1 false)
6464 call i8* @__strcpy_chk(i8* %dst, i8* %src, i32 %len)
6565 ret void
6666 }
7272 %dst = getelementptr inbounds [60 x i8]* @a, i32 0, i32 0
7373
7474 ; CHECK: getelementptr inbounds ([60 x i8]* @a, i32 0, i32 0)
75 %len = call i32 @llvm.objectsize.i32(i8* %dst, i1 false)
75 %len = call i32 @llvm.objectsize.i32.p0i8(i8* %dst, i1 false)
7676 %ret = call i8* @__strcpy_chk(i8* %dst, i8* %dst, i32 %len)
7777 ret i8* %ret
7878 }
9090 }
9191
9292 declare i8* @__strcpy_chk(i8*, i8*, i32) nounwind
93 declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly
93 declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) nounwind readonly