llvm.org GIT mirror llvm / bbcec68
Put CPPBackend tests into their own directory and run them only if they're supported. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53427 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 11 years ago
5 changed file(s) with 768 addition(s) and 763 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-as < %s | llc -march=cpp -cppfname=WAKKA | not grep makeLLVMModule
1 ; PR1515
2
3 define void @foo() {
4 ret void
5 }
6
0 load_lib llvm.exp
1
2 if { [llvm_supports_target CppBackend] } {
3 RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
4 }
0 ; RUN: llvm-as < %s | llvm-dis > /dev/null
1 ; RUN: llvm-as < %s | llc -march=cpp -cppgen=program -o -
2
3 @X = global i32 4, align 16 ; [#uses=0]
4
5 define i32* @test1012() align 32 {
6 %X = alloca i32, align 4 ; [#uses=1]
7 %Y = alloca i32, i32 42, align 16 ; [#uses=0]
8 %Z = alloca i32 ; [#uses=0]
9 ret i32* %X
10 }
11
12 define i32* @test1013() {
13 %X = malloc i32, align 4 ; [#uses=1]
14 %Y = malloc i32, i32 42, align 16 ; [#uses=0]
15 %Z = malloc i32 ; [#uses=0]
16 ret i32* %X
17 }
18
19 define void @void(i32, i32) {
20 add i32 0, 0 ; :3 [#uses=2]
21 sub i32 0, 4 ; :4 [#uses=2]
22 br label %5
23
24 ;
25 add i32 %0, %1 ; :6 [#uses=2]
26 sub i32 %6, %4 ; :7 [#uses=1]
27 icmp sle i32 %7, %3 ; :8 [#uses=1]
28 br i1 %8, label %9, label %5
29
30 ;
31 add i32 %0, %1 ; :10 [#uses=0]
32 sub i32 %6, %4 ; :11 [#uses=1]
33 icmp sle i32 %11, %3 ; :12 [#uses=0]
34 ret void
35 }
36
37 define i32 @zarro() {
38 Startup:
39 ret i32 0
40 }
41
42 define fastcc void @foo() {
43 ret void
44 }
45
46 define coldcc void @bar() {
47 call fastcc void @foo( )
48 ret void
49 }
50
51 define void @structret({ i8 }* sret %P) {
52 call void @structret( { i8 }* %P sret )
53 ret void
54 }
55
56 define void @foo4() {
57 ret void
58 }
59
60 define coldcc void @bar2() {
61 call fastcc void @foo( )
62 ret void
63 }
64
65 define cc42 void @bar3() {
66 invoke fastcc void @foo( )
67 to label %Ok unwind label %U
68
69 Ok: ; preds = %0
70 ret void
71
72 U: ; preds = %0
73 unwind
74 }
75
76 define void @bar4() {
77 call cc42 void @bar( )
78 invoke cc42 void @bar3( )
79 to label %Ok unwind label %U
80
81 Ok: ; preds = %0
82 ret void
83
84 U: ; preds = %0
85 unwind
86 }
87 ; ModuleID = 'calltest.ll'
88 %FunTy = type i32 (i32)
89
90 define i32 @test1000(i32 %i0) {
91 ret i32 %i0
92 }
93
94 define void @invoke(%FunTy* %x) {
95 %foo = call i32 %x( i32 123 ) ; [#uses=0]
96 %foo2 = tail call i32 %x( i32 123 ) ; [#uses=0]
97 ret void
98 }
99
100 define i32 @main(i32 %argc) {
101 %retval = call i32 @test1000( i32 %argc ) ; [#uses=2]
102 %two = add i32 %retval, %retval ; [#uses=1]
103 %retval2 = invoke i32 @test1000( i32 %argc )
104 to label %Next unwind label %Error ; [#uses=1]
105
106 Next: ; preds = %0
107 %two2 = add i32 %two, %retval2 ; [#uses=1]
108 call void @invoke( %FunTy* @test1000 )
109 ret i32 %two2
110
111 Error: ; preds = %0
112 ret i32 -1
113 }
114 ; ModuleID = 'casttest.ll'
115
116 define i16 @FunFunc(i64 %x, i8 %z) {
117 bb0:
118 %cast110 = sext i8 %z to i16 ; [#uses=1]
119 %cast10 = trunc i64 %x to i16 ; [#uses=1]
120 %reg109 = add i16 %cast110, %cast10 ; [#uses=1]
121 ret i16 %reg109
122 }
123 ; ModuleID = 'cfgstructures.ll'
124
125 define void @irreducible(i1 %cond) {
126 br i1 %cond, label %X, label %Y
127
128 X: ; preds = %Y, %0
129 br label %Y
130
131 Y: ; preds = %X, %0
132 br label %X
133 }
134
135 define void @sharedheader(i1 %cond) {
136 br label %A
137
138 A: ; preds = %Y, %X, %0
139 br i1 %cond, label %X, label %Y
140
141 X: ; preds = %A
142 br label %A
143
144 Y: ; preds = %A
145 br label %A
146 }
147
148 define void @nested(i1 %cond1, i1 %cond2, i1 %cond3) {
149 br label %Loop1
150
151 Loop1: ; preds = %L2Exit, %0
152 br label %Loop2
153
154 Loop2: ; preds = %L3Exit, %Loop1
155 br label %Loop3
156
157 Loop3: ; preds = %Loop3, %Loop2
158 br i1 %cond3, label %Loop3, label %L3Exit
159
160 L3Exit: ; preds = %Loop3
161 br i1 %cond2, label %Loop2, label %L2Exit
162
163 L2Exit: ; preds = %L3Exit
164 br i1 %cond1, label %Loop1, label %L1Exit
165
166 L1Exit: ; preds = %L2Exit
167 ret void
168 }
169 ; ModuleID = 'constexpr.ll'
170 %SAType = type { i32, { [2 x float], i64 } }
171 %SType = type { i32, { float, { i8 } }, i64 }
172 global i64 1 ; :0 [#uses=0]
173 global i64 74514 ; :1 [#uses=0]
174 @t2 = global i32* @t1 ; [#uses=0]
175 @t3 = global i32* @t1 ; [#uses=2]
176 @t1 = global i32 4 ; [#uses=2]
177 @t4 = global i32** @t3 ; [#uses=1]
178 @t5 = global i32** @t3 ; [#uses=0]
179 @t6 = global i32*** @t4 ; [#uses=0]
180 @t7 = global float* inttoptr (i32 12345678 to float*) ; [#uses=0]
181 @t9 = global i32 8 ; [#uses=0]
182 global i32* bitcast (float* @4 to i32*) ; :2 [#uses=0]
183 global float* @4 ; :3 [#uses=0]
184 global float 0.000000e+00 ; :4 [#uses=2]
185 @array = constant [2 x i32] [ i32 12, i32 52 ] ; <[2 x i32]*> [#uses=1]
186 @arrayPtr = global i32* getelementptr ([2 x i32]* @array, i64 0, i64 0) ; [#uses=1]
187 @arrayPtr5 = global i32** getelementptr (i32** @arrayPtr, i64 5) ; [#uses=0]
188 @somestr = constant [11 x i8] c"hello world" ; <[11 x i8]*> [#uses=2]
189 @char5 = global i8* getelementptr ([11 x i8]* @somestr, i64 0, i64 5) ; [#uses=0]
190 @char8a = global i32* bitcast (i8* getelementptr ([11 x i8]* @somestr, i64 0, i64 8) to i32*) ; [#uses=0]
191 @char8b = global i8* getelementptr ([11 x i8]* @somestr, i64 0, i64 8) ; [#uses=0]
192 @S1 = global %SType* null ; <%SType**> [#uses=1]
193 @S2c = constant %SType {
194 i32 1,
195 { float, { i8 } } { float 2.000000e+00, { i8 } { i8 3 } },
196 i64 4 } ; <%SType*> [#uses=3]
197 @S3c = constant %SAType { i32 1, { [2 x float], i64 } { [2 x float] [ float 2.000000e+00, float 3.000000e+00 ], i64 4 } } ; <%SAType*> [#uses=1]
198 @S1ptr = global %SType** @S1 ; <%SType***> [#uses=0]
199 @S2 = global %SType* @S2c ; <%SType**> [#uses=0]
200 @S3 = global %SAType* @S3c ; <%SAType**> [#uses=0]
201 @S1fld1a = global float* getelementptr (%SType* @S2c, i64 0, i32 1, i32 0) ; [#uses=0]
202 @S1fld1b = global float* getelementptr (%SType* @S2c, i64 0, i32 1, i32 0) ; [#uses=1]
203 @S1fld1bptr = global float** @S1fld1b ; [#uses=0]
204 @S2fld3 = global i8* getelementptr (%SType* @S2c, i64 0, i32 1, i32 1, i32 0) ; [#uses=0]
205
206 ; ModuleID = 'constpointer.ll'
207 @cpt3 = global i32* @cpt1 ; [#uses=1]
208 @cpt1 = global i32 4 ; [#uses=2]
209 @cpt4 = global i32** @cpt3 ; [#uses=0]
210 @cpt2 = global i32* @cpt1 ; [#uses=0]
211 global float* @7 ; :0 [#uses=0]
212 global float* @7 ; :1 [#uses=0]
213 global float 0.000000e+00 ; :2 [#uses=3]
214 global float* @7 ; :3 [#uses=0]
215 @fptr = global void ()* @f ; [#uses=0]
216 @sptr1 = global [11 x i8]* @somestr ; <[11 x i8]**> [#uses=0]
217 @somestr2 = constant [11 x i8] c"hello world" ; <[11 x i8]*> [#uses=2]
218 @sptr2 = global [11 x i8]* @somestr2 ; <[11 x i8]**> [#uses=0]
219
220 declare void @f()
221 ; ModuleID = 'escaped_label.ll'
222
223 define i32 @foo3() {
224 br label "foo`~!@#$%^&*()-_=+{}[]\\|;:',<.>/?"
225
226 "foo`~!@#$%^&*()-_=+{}[]\\|;:',<.>/?": ; preds = %0
227 ret i32 17
228 }
229 ; ModuleID = 'float.ll'
230 @F1 = global float 4.000000e+00 ; [#uses=0]
231 @D1 = global double 4.000000e+00 ; [#uses=0]
232 ; ModuleID = 'fold-fpcast.ll'
233
234 define i32 @test1() {
235 ret i32 1080872141
236 }
237
238 define float @test1002() {
239 ret float 0x36E1000000000000
240 }
241
242 define i64 @test3() {
243 ret i64 4614256656431372362
244 }
245
246 define double @test4() {
247 ret double 2.075076e-322
248 }
249 ; ModuleID = 'forwardreftest.ll'
250 %myfn = type float (i32, double, i32, i16)
251 %myty = type i32
252 %thisfuncty = type i32 (i32)*
253
254 declare void @F(%thisfuncty, %thisfuncty, %thisfuncty)
255
256 define i32 @zarro2(i32 %Func) {
257 Startup:
258 add i32 0, 10 ; :0 [#uses=0]
259 ret i32 0
260 }
261
262 define i32 @test1004(i32) {
263 call void @F( %thisfuncty @zarro2, %thisfuncty @test1004, %thisfuncty @foozball )
264 ret i32 0
265 }
266
267 define i32 @foozball(i32) {
268 ret i32 0
269 }
270
271 ; ModuleID = 'globalredefinition.ll'
272 @A = global i32* @B ; [#uses=0]
273 @B = global i32 7 ; [#uses=1]
274
275 define void @X() {
276 ret void
277 }
278 ; ModuleID = 'global_section.ll'
279 @GlobSec = global i32 4, section "foo", align 16
280
281 define void @test1005() section "bar" {
282 ret void
283 }
284
285 ; ModuleID = 'globalvars.ll'
286 @MyVar = external global i32 ; [#uses=1]
287 @MyIntList = external global { \2*, i32 } ; <{ \2*, i32 }*> [#uses=1]
288 external global i32 ; :0 [#uses=0]
289 @AConst = constant i32 123 ; [#uses=0]
290 @AString = constant [4 x i8] c"test" ; <[4 x i8]*> [#uses=0]
291 @ZeroInit = global { [100 x i32], [40 x float] } zeroinitializer ; <{ [100 x i32], [40 x float] }*> [#uses=0]
292
293 define i32 @foo10015(i32 %blah) {
294 store i32 5, i32* @MyVar
295 %idx = getelementptr { \2*, i32 }* @MyIntList, i64 0, i32 1 ; [#uses=1]
296 store i32 12, i32* %idx
297 ret i32 %blah
298 }
299 ; ModuleID = 'indirectcall2.ll'
300
301 define i64 @test1006(i64 %X) {
302 ret i64 %X
303 }
304
305 define i64 @fib(i64 %n) {
306 ;
307 %T = icmp ult i64 %n, 2 ; [#uses=1]
308 br i1 %T, label %BaseCase, label %RecurseCase
309
310 RecurseCase: ; preds = %0
311 %result = call i64 @test1006( i64 %n ) ; [#uses=0]
312 br label %BaseCase
313
314 BaseCase: ; preds = %RecurseCase, %0
315 %X = phi i64 [ 1, %0 ], [ 2, %RecurseCase ] ; [#uses=1]
316 ret i64 %X
317 }
318 ; ModuleID = 'indirectcall.ll'
319
320 declare i32 @atoi(i8*)
321
322 define i64 @fibonacc(i64 %n) {
323 icmp ult i64 %n, 2 ; :1 [#uses=1]
324 br i1 %1, label %BaseCase, label %RecurseCase
325
326 BaseCase: ; preds = %0
327 ret i64 1
328
329 RecurseCase: ; preds = %0
330 %n2 = sub i64 %n, 2 ; [#uses=1]
331 %n1 = sub i64 %n, 1 ; [#uses=1]
332 %f2 = call i64 @fibonacc( i64 %n2 ) ; [#uses=1]
333 %f1 = call i64 @fibonacc( i64 %n1 ) ; [#uses=1]
334 %result = add i64 %f2, %f1 ; [#uses=1]
335 ret i64 %result
336 }
337
338 define i64 @realmain(i32 %argc, i8** %argv) {
339 ;
340 icmp eq i32 %argc, 2 ; :1 [#uses=1]
341 br i1 %1, label %HasArg, label %Continue
342
343 HasArg: ; preds = %0
344 %n1 = add i32 1, 1 ; [#uses=1]
345 br label %Continue
346
347 Continue: ; preds = %HasArg, %0
348 %n = phi i32 [ %n1, %HasArg ], [ 1, %0 ] ; [#uses=1]
349 %N = sext i32 %n to i64 ; [#uses=1]
350 %F = call i64 @fib( i64 %N ) ; [#uses=1]
351 ret i64 %F
352 }
353
354 define i64 @trampoline(i64 %n, i64 (i64)* %fibfunc) {
355 %F = call i64 %fibfunc( i64 %n ) ; [#uses=1]
356 ret i64 %F
357 }
358
359 define i32 @main2() {
360 %Result = call i64 @trampoline( i64 10, i64 (i64)* @fib ) ; [#uses=1]
361 %Result.upgrd.1 = trunc i64 %Result to i32 ; [#uses=1]
362 ret i32 %Result.upgrd.1
363 }
364 ; ModuleID = 'inlineasm.ll'
365 module asm "this is an inline asm block"
366 module asm "this is another inline asm block"
367
368 define i32 @test1007() {
369 %X = call i32 asm "tricky here $0, $1", "=r,r"( i32 4 ) ; [#uses=1]
370 call void asm sideeffect "eieio", ""( )
371 ret i32 %X
372 }
373 ; ModuleID = 'instructions.ll'
374
375 define i32 @test_extractelement(<4 x i32> %V) {
376 %R = extractelement <4 x i32> %V, i32 1 ; [#uses=1]
377 ret i32 %R
378 }
379
380 define <4 x i32> @test_insertelement(<4 x i32> %V) {
381 %R = insertelement <4 x i32> %V, i32 0, i32 0 ; <<4 x i32>> [#uses=1]
382 ret <4 x i32> %R
383 }
384
385 define <4 x i32> @test_shufflevector_u(<4 x i32> %V) {
386 %R = shufflevector <4 x i32> %V, <4 x i32> %V, <4 x i32> < i32 1, i32 undef, i32 7, i32 2 > ; <<4 x i32>> [#uses=1]
387 ret <4 x i32> %R
388 }
389
390 define <4 x float> @test_shufflevector_f(<4 x float> %V) {
391 %R = shufflevector <4 x float> %V, <4 x float> undef, <4 x i32> < i32 1, i32 undef, i32 7, i32 2 > ; <<4 x float>> [#uses=1]
392 ret <4 x float> %R
393 }
394 ; ModuleID = 'intrinsics.ll'
395
396 declare i1 @llvm.isunordered.f32(float, float)
397
398 declare i1 @llvm.isunordered.f64(double, double)
399
400 declare void @llvm.prefetch(i8*, i32, i32)
401
402 declare float @llvm.sqrt.f32(float)
403
404 declare double @llvm.sqrt.f64(double)
405
406 define void @libm() {
407 fcmp uno float 1.000000e+00, 2.000000e+00 ; :1 [#uses=0]
408 fcmp uno double 3.000000e+00, 4.000000e+00 ; :2 [#uses=0]
409 call void @llvm.prefetch( i8* null, i32 1, i32 3 )
410 call float @llvm.sqrt.f32( float 5.000000e+00 ) ; :3 [#uses=0]
411 call double @llvm.sqrt.f64( double 6.000000e+00 ) ; :4 [#uses=0]
412 call i8 @llvm.ctpop.i8( i8 10 ) ; :5 [#uses=1]
413 call i16 @llvm.ctpop.i16( i16 11 ) ; :7 [#uses=1]
414 call i32 @llvm.ctpop.i32( i32 12 ) ; :9 [#uses=1]
415 call i64 @llvm.ctpop.i64( i64 13 ) ; :11 [#uses=1]
416 call i8 @llvm.ctlz.i8( i8 14 ) ; :13 [#uses=1]
417 call i16 @llvm.ctlz.i16( i16 15 ) ; :15 [#uses=1]
418 call i32 @llvm.ctlz.i32( i32 16 ) ; :17 [#uses=1]
419 call i64 @llvm.ctlz.i64( i64 17 ) ; :19 [#uses=1]
420 call i8 @llvm.cttz.i8( i8 18 ) ; :21 [#uses=1]
421 call i16 @llvm.cttz.i16( i16 19 ) ; :23 [#uses=1]
422 call i32 @llvm.cttz.i32( i32 20 ) ; :25 [#uses=1]
423 call i64 @llvm.cttz.i64( i64 21 ) ; :27 [#uses=1]
424 ret void
425 }
426
427 declare i8 @llvm.ctpop.i8(i8)
428
429 declare i16 @llvm.ctpop.i16(i16)
430
431 declare i32 @llvm.ctpop.i32(i32)
432
433 declare i64 @llvm.ctpop.i64(i64)
434
435 declare i8 @llvm.ctlz.i8(i8)
436
437 declare i16 @llvm.ctlz.i16(i16)
438
439 declare i32 @llvm.ctlz.i32(i32)
440
441 declare i64 @llvm.ctlz.i64(i64)
442
443 declare i8 @llvm.cttz.i8(i8)
444
445 declare i16 @llvm.cttz.i16(i16)
446
447 declare i32 @llvm.cttz.i32(i32)
448
449 declare i64 @llvm.cttz.i64(i64)
450
451 ; ModuleID = 'packed.ll'
452 @foo1 = external global <4 x float> ; <<4 x float>*> [#uses=2]
453 @foo102 = external global <2 x i32> ; <<2 x i32>*> [#uses=2]
454
455 define void @main3() {
456 store <4 x float> < float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00 >, <4 x float>* @foo1
457 store <2 x i32> < i32 4, i32 4 >, <2 x i32>* @foo102
458 %l1 = load <4 x float>* @foo1 ; <<4 x float>> [#uses=0]
459 %l2 = load <2 x i32>* @foo102 ; <<2 x i32>> [#uses=0]
460 ret void
461 }
462
463 ; ModuleID = 'properties.ll'
464 target datalayout = "e-p:32:32"
465 target triple = "proc-vend-sys"
466 deplibs = [ "m", "c" ]
467 ; ModuleID = 'prototype.ll'
468
469 declare i32 @bar1017(i32 %in)
470
471 define i32 @foo1016(i32 %blah) {
472 %xx = call i32 @bar1017( i32 %blah ) ; [#uses=1]
473 ret i32 %xx
474 }
475
476 ; ModuleID = 'recursivetype.ll'
477 %list = type { %list*, i32 }
478
479 declare i8* @malloc(i32)
480
481 define void @InsertIntoListTail(%list** %L, i32 %Data) {
482 bb1:
483 %reg116 = load %list** %L ; <%list*> [#uses=1]
484 %cast1004 = inttoptr i64 0 to %list* ; <%list*> [#uses=1]
485 %cond1000 = icmp eq %list* %reg116, %cast1004 ; [#uses=1]
486 br i1 %cond1000, label %bb3, label %bb2
487
488 bb2: ; preds = %bb2, %bb1
489 %reg117 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ] ; <%list**> [#uses=1]
490 %cast1010 = bitcast %list** %reg117 to %list*** ; <%list***> [#uses=1]
491 %reg118 = load %list*** %cast1010 ; <%list**> [#uses=3]
492 %reg109 = load %list** %reg118 ; <%list*> [#uses=1]
493 %cast1005 = inttoptr i64 0 to %list* ; <%list*> [#uses=1]
494 %cond1001 = icmp ne %list* %reg109, %cast1005 ; [#uses=1]
495 br i1 %cond1001, label %bb2, label %bb3
496
497 bb3: ; preds = %bb2, %bb1
498 %reg119 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ] ; <%list**> [#uses=1]
499 %cast1006 = bitcast %list** %reg119 to i8** ; [#uses=1]
500 %reg111 = call i8* @malloc( i32 16 ) ; [#uses=3]
501 store i8* %reg111, i8** %cast1006
502 %reg111.upgrd.1 = ptrtoint i8* %reg111 to i64 ; [#uses=1]
503 %reg1002 = add i64 %reg111.upgrd.1, 8 ; [#uses=1]
504 %reg1002.upgrd.2 = inttoptr i64 %reg1002 to i8* ; [#uses=1]
505 %cast1008 = bitcast i8* %reg1002.upgrd.2 to i32* ; [#uses=1]
506 store i32 %Data, i32* %cast1008
507 %cast1003 = inttoptr i64 0 to i64* ; [#uses=1]
508 %cast1009 = bitcast i8* %reg111 to i64** ; [#uses=1]
509 store i64* %cast1003, i64** %cast1009
510 ret void
511 }
512
513 define %list* @FindData(%list* %L, i32 %Data) {
514 bb1:
515 br label %bb2
516
517 bb2: ; preds = %bb6, %bb1
518 %reg115 = phi %list* [ %reg116, %bb6 ], [ %L, %bb1 ] ; <%list*> [#uses=4]
519 %cast1014 = inttoptr i64 0 to %list* ; <%list*> [#uses=1]
520 %cond1011 = icmp ne %list* %reg115, %cast1014 ; [#uses=1]
521 br i1 %cond1011, label %bb4, label %bb3
522
523 bb3: ; preds = %bb2
524 ret %list* null
525
526 bb4: ; preds = %bb2
527 %idx = getelementptr %list* %reg115, i64 0, i32 1 ; [#uses=1]
528 %reg111 = load i32* %idx ; [#uses=1]
529 %cond1013 = icmp ne i32 %reg111, %Data ; [#uses=1]
530 br i1 %cond1013, label %bb6, label %bb5
531
532 bb5: ; preds = %bb4
533 ret %list* %reg115
534
535 bb6: ; preds = %bb4
536 %idx2 = getelementptr %list* %reg115, i64 0, i32 0 ; <%list**> [#uses=1]
537 %reg116 = load %list** %idx2 ; <%list*> [#uses=1]
538 br label %bb2
539 }
540 ; ModuleID = 'simplecalltest.ll'
541 %FunTy = type i32 (i32)
542
543 define void @invoke1019(%FunTy* %x) {
544 %foo = call i32 %x( i32 123 ) ; [#uses=0]
545 ret void
546 }
547
548 define i32 @main4(i32 %argc, i8** %argv, i8** %envp) {
549 %retval = call i32 @test1008( i32 %argc ) ; [#uses=2]
550 %two = add i32 %retval, %retval ; [#uses=1]
551 %retval2 = call i32 @test1008( i32 %argc ) ; [#uses=1]
552 %two2 = add i32 %two, %retval2 ; [#uses=1]
553 call void @invoke1019( %FunTy* @test1008 )
554 ret i32 %two2
555 }
556
557 define i32 @test1008(i32 %i0) {
558 ret i32 %i0
559 }
560 ; ModuleID = 'smallest.ll'
561 ; ModuleID = 'small.ll'
562 %x = type i32
563
564 define i32 @foo1020(i32 %in) {
565 label:
566 ret i32 2
567 }
568 ; ModuleID = 'testalloca.ll'
569 %inners = type { float, { i8 } }
570 %struct = type { i32, %inners, i64 }
571
572 define i32 @testfunction(i32 %i0, i32 %j0) {
573 alloca i8, i32 5 ; :1 [#uses=0]
574 %ptr = alloca i32 ; [#uses=2]
575 store i32 3, i32* %ptr
576 %val = load i32* %ptr ; [#uses=0]
577 %sptr = alloca %struct ; <%struct*> [#uses=2]
578 %nsptr = getelementptr %struct* %sptr, i64 0, i32 1 ; <%inners*> [#uses=1]
579 %ubsptr = getelementptr %inners* %nsptr, i64 0, i32 1 ; <{ i8 }*> [#uses=1]
580 %idx = getelementptr { i8 }* %ubsptr, i64 0, i32 0 ; [#uses=1]
581 store i8 4, i8* %idx
582 %fptr = getelementptr %struct* %sptr, i64 0, i32 1, i32 0 ; [#uses=1]
583 store float 4.000000e+00, float* %fptr
584 ret i32 3
585 }
586 ; ModuleID = 'testconstants.ll'
587 @somestr3 = constant [11 x i8] c"hello world"
588 @array99 = constant [2 x i32] [ i32 12, i32 52 ]
589 constant { i32, i32 } { i32 4, i32 3 } ; <{ i32, i32 }*>:0 [#uses=0]
590
591 define [2 x i32]* @testfunction99(i32 %i0, i32 %j0) {
592 ret [2 x i32]* @array
593 }
594
595 define i8* @otherfunc(i32, double) {
596 %somestr = getelementptr [11 x i8]* @somestr3, i64 0, i64 0 ; [#uses=1]
597 ret i8* %somestr
598 }
599
600 define i8* @yetanotherfunc(i32, double) {
601 ret i8* null
602 }
603
604 define i32 @negativeUnsigned() {
605 ret i32 -1
606 }
607
608 define i32 @largeSigned() {
609 ret i32 -394967296
610 }
611 ; ModuleID = 'testlogical.ll'
612
613 define i32 @simpleAdd(i32 %i0, i32 %j0) {
614 %t1 = xor i32 %i0, %j0 ; [#uses=1]
615 %t2 = or i32 %i0, %j0 ; [#uses=1]
616 %t3 = and i32 %t1, %t2 ; [#uses=1]
617 ret i32 %t3
618 }
619 ; ModuleID = 'testmemory.ll'
620 %complexty = type { i32, { [4 x i8*], float }, double }
621 %struct = type { i32, { float, { i8 } }, i64 }
622
623 define i32 @main6() {
624 call i32 @testfunction98( i64 0, i64 1 )
625 ret i32 0
626 }
627
628 define i32 @testfunction98(i64 %i0, i64 %j0) {
629 %array0 = malloc [4 x i8] ; <[4 x i8]*> [#uses=2]
630 %size = add i32 2, 2 ; [#uses=1]
631 %array1 = malloc i8, i32 4 ; [#uses=1]
632 %array2 = malloc i8, i32 %size ; [#uses=1]
633 %idx = getelementptr [4 x i8]* %array0, i64 0, i64 2 ; [#uses=1]
634 store i8 123, i8* %idx
635 free [4 x i8]* %array0
636 free i8* %array1
637 free i8* %array2
638 %aa = alloca %complexty, i32 5 ; <%complexty*> [#uses=1]
639 %idx2 = getelementptr %complexty* %aa, i64 %i0, i32 1, i32 0, i64 %j0 ; [#uses=1]
640 store i8* null, i8** %idx2
641 %ptr = alloca i32 ; [#uses=2]
642 store i32 3, i32* %ptr
643 %val = load i32* %ptr ; [#uses=0]
644 %sptr = alloca %struct ; <%struct*> [#uses=1]
645 %ubsptr = getelementptr %struct* %sptr, i64 0, i32 1, i32 1 ; <{ i8 }*> [#uses=1]
646 %idx3 = getelementptr { i8 }* %ubsptr, i64 0, i32 0 ; [#uses=1]
647 store i8 4, i8* %idx3
648 ret i32 3
649 }
650 ; ModuleID = 'testswitch.ll'
651 %int = type i32
652
653 define i32 @squared(i32 %i0) {
654 switch i32 %i0, label %Default [
655 i32 1, label %Case1
656 i32 2, label %Case2
657 i32 4, label %Case4
658 ]
659
660 Default: ; preds = %0
661 ret i32 -1
662
663 Case1: ; preds = %0
664 ret i32 1
665
666 Case2: ; preds = %0
667 ret i32 4
668
669 Case4: ; preds = %0
670 ret i32 16
671 }
672 ; ModuleID = 'testvarargs.ll'
673
674 declare i32 @printf(i8*, ...)
675
676 define i32 @testvarar() {
677 call i32 (i8*, ...)* @printf( i8* null, i32 12, i8 42 ) ; :1 [#uses=1]
678 ret i32 %1
679 }
680 ; ModuleID = 'undefined.ll'
681 @X2 = global i32 undef ; [#uses=0]
682
683 declare i32 @atoi(i8*)
684
685 define i32 @test1009() {
686 ret i32 undef
687 }
688
689 define i32 @test1003() {
690 %X = add i32 undef, 1 ; [#uses=1]
691 ret i32 %X
692 }
693 ; ModuleID = 'unreachable.ll'
694
695 declare void @bar()
696
697 define i32 @foo1021() {
698 unreachable
699 }
700
701 define double @xyz() {
702 call void @bar( )
703 unreachable
704 }
705 ; ModuleID = 'varargs.ll'
706
707 declare void @llvm.va_start(i8* %ap)
708
709 declare void @llvm.va_copy(i8* %aq, i8* %ap)
710
711 declare void @llvm.va_end(i8* %ap)
712
713 define i32 @test1010(i32 %X, ...) {
714 %ap = alloca i8* ; [#uses=4]
715 %va.upgrd.1 = bitcast i8** %ap to i8* ; [#uses=1]
716 call void @llvm.va_start( i8* %va.upgrd.1 )
717 %tmp = va_arg i8** %ap, i32 ; [#uses=1]
718 %aq = alloca i8* ; [#uses=2]
719 %va0.upgrd.2 = bitcast i8** %aq to i8* ; [#uses=1]
720 %va1.upgrd.3 = bitcast i8** %ap to i8* ; [#uses=1]
721 call void @llvm.va_copy( i8* %va0.upgrd.2, i8* %va1.upgrd.3 )
722 %va.upgrd.4 = bitcast i8** %aq to i8* ; [#uses=1]
723 call void @llvm.va_end( i8* %va.upgrd.4 )
724 %va.upgrd.5 = bitcast i8** %ap to i8* ; [#uses=1]
725 call void @llvm.va_end( i8* %va.upgrd.5 )
726 ret i32 %tmp
727 }
728 ; ModuleID = 'varargs_new.ll'
729
730 declare void @llvm.va_start(i8*)
731
732 declare void @llvm.va_copy(i8*, i8*)
733
734 declare void @llvm.va_end(i8*)
735
736 define i32 @test1011(i32 %X, ...) {
737 %ap = alloca i8* ; [#uses=4]
738 %aq = alloca i8* ; [#uses=2]
739 %va.upgrd.1 = bitcast i8** %ap to i8* ; [#uses=1]
740 call void @llvm.va_start( i8* %va.upgrd.1 )
741 %tmp = va_arg i8** %ap, i32 ; [#uses=1]
742 %apv = load i8** %ap ; [#uses=1]
743 %va0.upgrd.2 = bitcast i8** %aq to i8* ; [#uses=1]
744 %va1.upgrd.3 = bitcast i8* %apv to i8* ; [#uses=1]
745 call void @llvm.va_copy( i8* %va0.upgrd.2, i8* %va1.upgrd.3 )
746 %va.upgrd.4 = bitcast i8** %aq to i8* ; [#uses=1]
747 call void @llvm.va_end( i8* %va.upgrd.4 )
748 %va.upgrd.5 = bitcast i8** %ap to i8* ; [#uses=1]
749 call void @llvm.va_end( i8* %va.upgrd.5 )
750 ret i32 %tmp
751 }
752 ; ModuleID = 'weirdnames.ll'
753 "&^ " = type { i32 }
754 @"%.*+ foo" = global "&^ " { i32 5 } ; <"&^ "*> [#uses=0]
755 @"0" = global float 0.000000e+00 ; [#uses=0]
+0
-756
test/Feature/llvm2cpp.ll less more
None ; RUN: llvm-as < %s | llvm-dis > /dev/null
1 ; RUN: llvm-as < %s | llc -march=cpp -cppgen=program -o -
2
3 @X = global i32 4, align 16 ; [#uses=0]
4
5 define i32* @test1012() align 32 {
6 %X = alloca i32, align 4 ; [#uses=1]
7 %Y = alloca i32, i32 42, align 16 ; [#uses=0]
8 %Z = alloca i32 ; [#uses=0]
9 ret i32* %X
10 }
11
12 define i32* @test1013() {
13 %X = malloc i32, align 4 ; [#uses=1]
14 %Y = malloc i32, i32 42, align 16 ; [#uses=0]
15 %Z = malloc i32 ; [#uses=0]
16 ret i32* %X
17 }
18
19 define void @void(i32, i32) {
20 add i32 0, 0 ; :3 [#uses=2]
21 sub i32 0, 4 ; :4 [#uses=2]
22 br label %5
23
24 ;
25 add i32 %0, %1 ; :6 [#uses=2]
26 sub i32 %6, %4 ; :7 [#uses=1]
27 icmp sle i32 %7, %3 ; :8 [#uses=1]
28 br i1 %8, label %9, label %5
29
30 ;
31 add i32 %0, %1 ; :10 [#uses=0]
32 sub i32 %6, %4 ; :11 [#uses=1]
33 icmp sle i32 %11, %3 ; :12 [#uses=0]
34 ret void
35 }
36
37 define i32 @zarro() {
38 Startup:
39 ret i32 0
40 }
41
42 define fastcc void @foo() {
43 ret void
44 }
45
46 define coldcc void @bar() {
47 call fastcc void @foo( )
48 ret void
49 }
50
51 define void @structret({ i8 }* sret %P) {
52 call void @structret( { i8 }* %P sret )
53 ret void
54 }
55
56 define void @foo4() {
57 ret void
58 }
59
60 define coldcc void @bar2() {
61 call fastcc void @foo( )
62 ret void
63 }
64
65 define cc42 void @bar3() {
66 invoke fastcc void @foo( )
67 to label %Ok unwind label %U
68
69 Ok: ; preds = %0
70 ret void
71
72 U: ; preds = %0
73 unwind
74 }
75
76 define void @bar4() {
77 call cc42 void @bar( )
78 invoke cc42 void @bar3( )
79 to label %Ok unwind label %U
80
81 Ok: ; preds = %0
82 ret void
83
84 U: ; preds = %0
85 unwind
86 }
87 ; ModuleID = 'calltest.ll'
88 %FunTy = type i32 (i32)
89
90 define i32 @test1000(i32 %i0) {
91 ret i32 %i0
92 }
93
94 define void @invoke(%FunTy* %x) {
95 %foo = call i32 %x( i32 123 ) ; [#uses=0]
96 %foo2 = tail call i32 %x( i32 123 ) ; [#uses=0]
97 ret void
98 }
99
100 define i32 @main(i32 %argc) {
101 %retval = call i32 @test1000( i32 %argc ) ; [#uses=2]
102 %two = add i32 %retval, %retval ; [#uses=1]
103 %retval2 = invoke i32 @test1000( i32 %argc )
104 to label %Next unwind label %Error ; [#uses=1]
105
106 Next: ; preds = %0
107 %two2 = add i32 %two, %retval2 ; [#uses=1]
108 call void @invoke( %FunTy* @test1000 )
109 ret i32 %two2
110
111 Error: ; preds = %0
112 ret i32 -1
113 }
114 ; ModuleID = 'casttest.ll'
115
116 define i16 @FunFunc(i64 %x, i8 %z) {
117 bb0:
118 %cast110 = sext i8 %z to i16 ; [#uses=1]
119 %cast10 = trunc i64 %x to i16 ; [#uses=1]
120 %reg109 = add i16 %cast110, %cast10 ; [#uses=1]
121 ret i16 %reg109
122 }
123 ; ModuleID = 'cfgstructures.ll'
124
125 define void @irreducible(i1 %cond) {
126 br i1 %cond, label %X, label %Y
127
128 X: ; preds = %Y, %0
129 br label %Y
130
131 Y: ; preds = %X, %0
132 br label %X
133 }
134
135 define void @sharedheader(i1 %cond) {
136 br label %A
137
138 A: ; preds = %Y, %X, %0
139 br i1 %cond, label %X, label %Y
140
141 X: ; preds = %A
142 br label %A
143
144 Y: ; preds = %A
145 br label %A
146 }
147
148 define void @nested(i1 %cond1, i1 %cond2, i1 %cond3) {
149 br label %Loop1
150
151 Loop1: ; preds = %L2Exit, %0
152 br label %Loop2
153
154 Loop2: ; preds = %L3Exit, %Loop1
155 br label %Loop3
156
157 Loop3: ; preds = %Loop3, %Loop2
158 br i1 %cond3, label %Loop3, label %L3Exit
159
160 L3Exit: ; preds = %Loop3
161 br i1 %cond2, label %Loop2, label %L2Exit
162
163 L2Exit: ; preds = %L3Exit
164 br i1 %cond1, label %Loop1, label %L1Exit
165
166 L1Exit: ; preds = %L2Exit
167 ret void
168 }
169 ; ModuleID = 'constexpr.ll'
170 %SAType = type { i32, { [2 x float], i64 } }
171 %SType = type { i32, { float, { i8 } }, i64 }
172 global i64 1 ; :0 [#uses=0]
173 global i64 74514 ; :1 [#uses=0]
174 @t2 = global i32* @t1 ; [#uses=0]
175 @t3 = global i32* @t1 ; [#uses=2]
176 @t1 = global i32 4 ; [#uses=2]
177 @t4 = global i32** @t3 ; [#uses=1]
178 @t5 = global i32** @t3 ; [#uses=0]
179 @t6 = global i32*** @t4 ; [#uses=0]
180 @t7 = global float* inttoptr (i32 12345678 to float*) ; [#uses=0]
181 @t9 = global i32 8 ; [#uses=0]
182 global i32* bitcast (float* @4 to i32*) ; :2 [#uses=0]
183 global float* @4 ; :3 [#uses=0]
184 global float 0.000000e+00 ; :4 [#uses=2]
185 @array = constant [2 x i32] [ i32 12, i32 52 ] ; <[2 x i32]*> [#uses=1]
186 @arrayPtr = global i32* getelementptr ([2 x i32]* @array, i64 0, i64 0) ; [#uses=1]
187 @arrayPtr5 = global i32** getelementptr (i32** @arrayPtr, i64 5) ; [#uses=0]
188 @somestr = constant [11 x i8] c"hello world" ; <[11 x i8]*> [#uses=2]
189 @char5 = global i8* getelementptr ([11 x i8]* @somestr, i64 0, i64 5) ; [#uses=0]
190 @char8a = global i32* bitcast (i8* getelementptr ([11 x i8]* @somestr, i64 0, i64 8) to i32*) ; [#uses=0]
191 @char8b = global i8* getelementptr ([11 x i8]* @somestr, i64 0, i64 8) ; [#uses=0]
192 @S1 = global %SType* null ; <%SType**> [#uses=1]
193 @S2c = constant %SType {
194 i32 1,
195 { float, { i8 } } { float 2.000000e+00, { i8 } { i8 3 } },
196 i64 4 } ; <%SType*> [#uses=3]
197 @S3c = constant %SAType { i32 1, { [2 x float], i64 } { [2 x float] [ float 2.000000e+00, float 3.000000e+00 ], i64 4 } } ; <%SAType*> [#uses=1]
198 @S1ptr = global %SType** @S1 ; <%SType***> [#uses=0]
199 @S2 = global %SType* @S2c ; <%SType**> [#uses=0]
200 @S3 = global %SAType* @S3c ; <%SAType**> [#uses=0]
201 @S1fld1a = global float* getelementptr (%SType* @S2c, i64 0, i32 1, i32 0) ; [#uses=0]
202 @S1fld1b = global float* getelementptr (%SType* @S2c, i64 0, i32 1, i32 0) ; [#uses=1]
203 @S1fld1bptr = global float** @S1fld1b ; [#uses=0]
204 @S2fld3 = global i8* getelementptr (%SType* @S2c, i64 0, i32 1, i32 1, i32 0) ; [#uses=0]
205
206 ; ModuleID = 'constpointer.ll'
207 @cpt3 = global i32* @cpt1 ; [#uses=1]
208 @cpt1 = global i32 4 ; [#uses=2]
209 @cpt4 = global i32** @cpt3 ; [#uses=0]
210 @cpt2 = global i32* @cpt1 ; [#uses=0]
211 global float* @7 ; :0 [#uses=0]
212 global float* @7 ; :1 [#uses=0]
213 global float 0.000000e+00 ; :2 [#uses=3]
214 global float* @7 ; :3 [#uses=0]
215 @fptr = global void ()* @f ; [#uses=0]
216 @sptr1 = global [11 x i8]* @somestr ; <[11 x i8]**> [#uses=0]
217 @somestr2 = constant [11 x i8] c"hello world" ; <[11 x i8]*> [#uses=2]
218 @sptr2 = global [11 x i8]* @somestr2 ; <[11 x i8]**> [#uses=0]
219
220 declare void @f()
221 ; ModuleID = 'escaped_label.ll'
222
223 define i32 @foo3() {
224 br label "foo`~!@#$%^&*()-_=+{}[]\\|;:',<.>/?"
225
226 "foo`~!@#$%^&*()-_=+{}[]\\|;:',<.>/?": ; preds = %0
227 ret i32 17
228 }
229 ; ModuleID = 'float.ll'
230 @F1 = global float 4.000000e+00 ; [#uses=0]
231 @D1 = global double 4.000000e+00 ; [#uses=0]
232 ; ModuleID = 'fold-fpcast.ll'
233
234 define i32 @test1() {
235 ret i32 1080872141
236 }
237
238 define float @test1002() {
239 ret float 0x36E1000000000000
240 }
241
242 define i64 @test3() {
243 ret i64 4614256656431372362
244 }
245
246 define double @test4() {
247 ret double 2.075076e-322
248 }
249 ; ModuleID = 'forwardreftest.ll'
250 %myfn = type float (i32, double, i32, i16)
251 %myty = type i32
252 %thisfuncty = type i32 (i32)*
253
254 declare void @F(%thisfuncty, %thisfuncty, %thisfuncty)
255
256 define i32 @zarro2(i32 %Func) {
257 Startup:
258 add i32 0, 10 ; :0 [#uses=0]
259 ret i32 0
260 }
261
262 define i32 @test1004(i32) {
263 call void @F( %thisfuncty @zarro2, %thisfuncty @test1004, %thisfuncty @foozball )
264 ret i32 0
265 }
266
267 define i32 @foozball(i32) {
268 ret i32 0
269 }
270
271 ; ModuleID = 'globalredefinition.ll'
272 @A = global i32* @B ; [#uses=0]
273 @B = global i32 7 ; [#uses=1]
274
275 define void @X() {
276 ret void
277 }
278 ; ModuleID = 'global_section.ll'
279 @GlobSec = global i32 4, section "foo", align 16
280
281 define void @test1005() section "bar" {
282 ret void
283 }
284
285 ; ModuleID = 'globalvars.ll'
286 @MyVar = external global i32 ; [#uses=1]
287 @MyIntList = external global { \2*, i32 } ; <{ \2*, i32 }*> [#uses=1]
288 external global i32 ; :0 [#uses=0]
289 @AConst = constant i32 123 ; [#uses=0]
290 @AString = constant [4 x i8] c"test" ; <[4 x i8]*> [#uses=0]
291 @ZeroInit = global { [100 x i32], [40 x float] } zeroinitializer ; <{ [100 x i32], [40 x float] }*> [#uses=0]
292
293 define i32 @foo10015(i32 %blah) {
294 store i32 5, i32* @MyVar
295 %idx = getelementptr { \2*, i32 }* @MyIntList, i64 0, i32 1 ; [#uses=1]
296 store i32 12, i32* %idx
297 ret i32 %blah
298 }
299 ; ModuleID = 'indirectcall2.ll'
300
301 define i64 @test1006(i64 %X) {
302 ret i64 %X
303 }
304
305 define i64 @fib(i64 %n) {
306 ;
307 %T = icmp ult i64 %n, 2 ; [#uses=1]
308 br i1 %T, label %BaseCase, label %RecurseCase
309
310 RecurseCase: ; preds = %0
311 %result = call i64 @test1006( i64 %n ) ; [#uses=0]
312 br label %BaseCase
313
314 BaseCase: ; preds = %RecurseCase, %0
315 %X = phi i64 [ 1, %0 ], [ 2, %RecurseCase ] ; [#uses=1]
316 ret i64 %X
317 }
318 ; ModuleID = 'indirectcall.ll'
319
320 declare i32 @atoi(i8*)
321
322 define i64 @fibonacc(i64 %n) {
323 icmp ult i64 %n, 2 ; :1 [#uses=1]
324 br i1 %1, label %BaseCase, label %RecurseCase
325
326 BaseCase: ; preds = %0
327 ret i64 1
328
329 RecurseCase: ; preds = %0
330 %n2 = sub i64 %n, 2 ; [#uses=1]
331 %n1 = sub i64 %n, 1 ; [#uses=1]
332 %f2 = call i64 @fibonacc( i64 %n2 ) ; [#uses=1]
333 %f1 = call i64 @fibonacc( i64 %n1 ) ; [#uses=1]
334 %result = add i64 %f2, %f1 ; [#uses=1]
335 ret i64 %result
336 }
337
338 define i64 @realmain(i32 %argc, i8** %argv) {
339 ;
340 icmp eq i32 %argc, 2 ; :1 [#uses=1]
341 br i1 %1, label %HasArg, label %Continue
342
343 HasArg: ; preds = %0
344 %n1 = add i32 1, 1 ; [#uses=1]
345 br label %Continue
346
347 Continue: ; preds = %HasArg, %0
348 %n = phi i32 [ %n1, %HasArg ], [ 1, %0 ] ; [#uses=1]
349 %N = sext i32 %n to i64 ; [#uses=1]
350 %F = call i64 @fib( i64 %N ) ; [#uses=1]
351 ret i64 %F
352 }
353
354 define i64 @trampoline(i64 %n, i64 (i64)* %fibfunc) {
355 %F = call i64 %fibfunc( i64 %n ) ; [#uses=1]
356 ret i64 %F
357 }
358
359 define i32 @main2() {
360 %Result = call i64 @trampoline( i64 10, i64 (i64)* @fib ) ; [#uses=1]
361 %Result.upgrd.1 = trunc i64 %Result to i32 ; [#uses=1]
362 ret i32 %Result.upgrd.1
363 }
364 ; ModuleID = 'inlineasm.ll'
365 module asm "this is an inline asm block"
366 module asm "this is another inline asm block"
367
368 define i32 @test1007() {
369 %X = call i32 asm "tricky here $0, $1", "=r,r"( i32 4 ) ; [#uses=1]
370 call void asm sideeffect "eieio", ""( )
371 ret i32 %X
372 }
373 ; ModuleID = 'instructions.ll'
374
375 define i32 @test_extractelement(<4 x i32> %V) {
376 %R = extractelement <4 x i32> %V, i32 1 ; [#uses=1]
377 ret i32 %R
378 }
379
380 define <4 x i32> @test_insertelement(<4 x i32> %V) {
381 %R = insertelement <4 x i32> %V, i32 0, i32 0 ; <<4 x i32>> [#uses=1]
382 ret <4 x i32> %R
383 }
384
385 define <4 x i32> @test_shufflevector_u(<4 x i32> %V) {
386 %R = shufflevector <4 x i32> %V, <4 x i32> %V, <4 x i32> < i32 1, i32 undef, i32 7, i32 2 > ; <<4 x i32>> [#uses=1]
387 ret <4 x i32> %R
388 }
389
390 define <4 x float> @test_shufflevector_f(<4 x float> %V) {
391 %R = shufflevector <4 x float> %V, <4 x float> undef, <4 x i32> < i32 1, i32 undef, i32 7, i32 2 > ; <<4 x float>> [#uses=1]
392 ret <4 x float> %R
393 }
394 ; ModuleID = 'intrinsics.ll'
395
396 declare i1 @llvm.isunordered.f32(float, float)
397
398 declare i1 @llvm.isunordered.f64(double, double)
399
400 declare void @llvm.prefetch(i8*, i32, i32)
401
402 declare float @llvm.sqrt.f32(float)
403
404 declare double @llvm.sqrt.f64(double)
405
406 define void @libm() {
407 fcmp uno float 1.000000e+00, 2.000000e+00 ; :1 [#uses=0]
408 fcmp uno double 3.000000e+00, 4.000000e+00 ; :2 [#uses=0]
409 call void @llvm.prefetch( i8* null, i32 1, i32 3 )
410 call float @llvm.sqrt.f32( float 5.000000e+00 ) ; :3 [#uses=0]
411 call double @llvm.sqrt.f64( double 6.000000e+00 ) ; :4 [#uses=0]
412 call i8 @llvm.ctpop.i8( i8 10 ) ; :5 [#uses=1]
413 call i16 @llvm.ctpop.i16( i16 11 ) ; :7 [#uses=1]
414 call i32 @llvm.ctpop.i32( i32 12 ) ; :9 [#uses=1]
415 call i64 @llvm.ctpop.i64( i64 13 ) ; :11 [#uses=1]
416 call i8 @llvm.ctlz.i8( i8 14 ) ; :13 [#uses=1]
417 call i16 @llvm.ctlz.i16( i16 15 ) ; :15 [#uses=1]
418 call i32 @llvm.ctlz.i32( i32 16 ) ; :17 [#uses=1]
419 call i64 @llvm.ctlz.i64( i64 17 ) ; :19 [#uses=1]
420 call i8 @llvm.cttz.i8( i8 18 ) ; :21 [#uses=1]
421 call i16 @llvm.cttz.i16( i16 19 ) ; :23 [#uses=1]
422 call i32 @llvm.cttz.i32( i32 20 ) ; :25 [#uses=1]
423 call i64 @llvm.cttz.i64( i64 21 ) ; :27 [#uses=1]
424 ret void
425 }
426
427 declare i8 @llvm.ctpop.i8(i8)
428
429 declare i16 @llvm.ctpop.i16(i16)
430
431 declare i32 @llvm.ctpop.i32(i32)
432
433 declare i64 @llvm.ctpop.i64(i64)
434
435 declare i8 @llvm.ctlz.i8(i8)
436
437 declare i16 @llvm.ctlz.i16(i16)
438
439 declare i32 @llvm.ctlz.i32(i32)
440
441 declare i64 @llvm.ctlz.i64(i64)
442
443 declare i8 @llvm.cttz.i8(i8)
444
445 declare i16 @llvm.cttz.i16(i16)
446
447 declare i32 @llvm.cttz.i32(i32)
448
449 declare i64 @llvm.cttz.i64(i64)
450
451 ; ModuleID = 'packed.ll'
452 @foo1 = external global <4 x float> ; <<4 x float>*> [#uses=2]
453 @foo102 = external global <2 x i32> ; <<2 x i32>*> [#uses=2]
454
455 define void @main3() {
456 store <4 x float> < float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00 >, <4 x float>* @foo1
457 store <2 x i32> < i32 4, i32 4 >, <2 x i32>* @foo102
458 %l1 = load <4 x float>* @foo1 ; <<4 x float>> [#uses=0]
459 %l2 = load <2 x i32>* @foo102 ; <<2 x i32>> [#uses=0]
460 ret void
461 }
462
463 ; ModuleID = 'properties.ll'
464 target datalayout = "e-p:32:32"
465 target triple = "proc-vend-sys"
466 deplibs = [ "m", "c" ]
467 ; ModuleID = 'prototype.ll'
468
469 declare i32 @bar1017(i32 %in)
470
471 define i32 @foo1016(i32 %blah) {
472 %xx = call i32 @bar1017( i32 %blah ) ; [#uses=1]
473 ret i32 %xx
474 }
475
476 ; ModuleID = 'recursivetype.ll'
477 %list = type { %list*, i32 }
478
479 declare i8* @malloc(i32)
480
481 define void @InsertIntoListTail(%list** %L, i32 %Data) {
482 bb1:
483 %reg116 = load %list** %L ; <%list*> [#uses=1]
484 %cast1004 = inttoptr i64 0 to %list* ; <%list*> [#uses=1]
485 %cond1000 = icmp eq %list* %reg116, %cast1004 ; [#uses=1]
486 br i1 %cond1000, label %bb3, label %bb2
487
488 bb2: ; preds = %bb2, %bb1
489 %reg117 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ] ; <%list**> [#uses=1]
490 %cast1010 = bitcast %list** %reg117 to %list*** ; <%list***> [#uses=1]
491 %reg118 = load %list*** %cast1010 ; <%list**> [#uses=3]
492 %reg109 = load %list** %reg118 ; <%list*> [#uses=1]
493 %cast1005 = inttoptr i64 0 to %list* ; <%list*> [#uses=1]
494 %cond1001 = icmp ne %list* %reg109, %cast1005 ; [#uses=1]
495 br i1 %cond1001, label %bb2, label %bb3
496
497 bb3: ; preds = %bb2, %bb1
498 %reg119 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ] ; <%list**> [#uses=1]
499 %cast1006 = bitcast %list** %reg119 to i8** ; [#uses=1]
500 %reg111 = call i8* @malloc( i32 16 ) ; [#uses=3]
501 store i8* %reg111, i8** %cast1006
502 %reg111.upgrd.1 = ptrtoint i8* %reg111 to i64 ; [#uses=1]
503 %reg1002 = add i64 %reg111.upgrd.1, 8 ; [#uses=1]
504 %reg1002.upgrd.2 = inttoptr i64 %reg1002 to i8* ; [#uses=1]
505 %cast1008 = bitcast i8* %reg1002.upgrd.2 to i32* ; [#uses=1]
506 store i32 %Data, i32* %cast1008
507 %cast1003 = inttoptr i64 0 to i64* ; [#uses=1]
508 %cast1009 = bitcast i8* %reg111 to i64** ; [#uses=1]
509 store i64* %cast1003, i64** %cast1009
510 ret void
511 }
512
513 define %list* @FindData(%list* %L, i32 %Data) {
514 bb1:
515 br label %bb2
516
517 bb2: ; preds = %bb6, %bb1
518 %reg115 = phi %list* [ %reg116, %bb6 ], [ %L, %bb1 ] ; <%list*> [#uses=4]
519 %cast1014 = inttoptr i64 0 to %list* ; <%list*> [#uses=1]
520 %cond1011 = icmp ne %list* %reg115, %cast1014 ; [#uses=1]
521 br i1 %cond1011, label %bb4, label %bb3
522
523 bb3: ; preds = %bb2
524 ret %list* null
525
526 bb4: ; preds = %bb2
527 %idx = getelementptr %list* %reg115, i64 0, i32 1 ; [#uses=1]
528 %reg111 = load i32* %idx ; [#uses=1]
529 %cond1013 = icmp ne i32 %reg111, %Data ; [#uses=1]
530 br i1 %cond1013, label %bb6, label %bb5
531
532 bb5: ; preds = %bb4
533 ret %list* %reg115
534
535 bb6: ; preds = %bb4
536 %idx2 = getelementptr %list* %reg115, i64 0, i32 0 ; <%list**> [#uses=1]
537 %reg116 = load %list** %idx2 ; <%list*> [#uses=1]
538 br label %bb2
539 }
540 ; ModuleID = 'simplecalltest.ll'
541 %FunTy = type i32 (i32)
542
543 define void @invoke1019(%FunTy* %x) {
544 %foo = call i32 %x( i32 123 ) ; [#uses=0]
545 ret void
546 }
547
548 define i32 @main4(i32 %argc, i8** %argv, i8** %envp) {
549 %retval = call i32 @test1008( i32 %argc ) ; [#uses=2]
550 %two = add i32 %retval, %retval ; [#uses=1]
551 %retval2 = call i32 @test1008( i32 %argc ) ; [#uses=1]
552 %two2 = add i32 %two, %retval2 ; [#uses=1]
553 call void @invoke1019( %FunTy* @test1008 )
554 ret i32 %two2
555 }
556
557 define i32 @test1008(i32 %i0) {
558 ret i32 %i0
559 }
560 ; ModuleID = 'smallest.ll'
561 ; ModuleID = 'small.ll'
562 %x = type i32
563
564 define i32 @foo1020(i32 %in) {
565 label:
566 ret i32 2
567 }
568 ; ModuleID = 'testalloca.ll'
569 %inners = type { float, { i8 } }
570 %struct = type { i32, %inners, i64 }
571
572 define i32 @testfunction(i32 %i0, i32 %j0) {
573 alloca i8, i32 5 ; :1 [#uses=0]
574 %ptr = alloca i32 ; [#uses=2]
575 store i32 3, i32* %ptr
576 %val = load i32* %ptr ; [#uses=0]
577 %sptr = alloca %struct ; <%struct*> [#uses=2]
578 %nsptr = getelementptr %struct* %sptr, i64 0, i32 1 ; <%inners*> [#uses=1]
579 %ubsptr = getelementptr %inners* %nsptr, i64 0, i32 1 ; <{ i8 }*> [#uses=1]
580 %idx = getelementptr { i8 }* %ubsptr, i64 0, i32 0 ; [#uses=1]
581 store i8 4, i8* %idx
582 %fptr = getelementptr %struct* %sptr, i64 0, i32 1, i32 0 ; [#uses=1]
583 store float 4.000000e+00, float* %fptr
584 ret i32 3
585 }
586 ; ModuleID = 'testconstants.ll'
587 @somestr3 = constant [11 x i8] c"hello world"
588 @array99 = constant [2 x i32] [ i32 12, i32 52 ]
589 constant { i32, i32 } { i32 4, i32 3 } ; <{ i32, i32 }*>:0 [#uses=0]
590
591 define [2 x i32]* @testfunction99(i32 %i0, i32 %j0) {
592 ret [2 x i32]* @array
593 }
594
595 define i8* @otherfunc(i32, double) {
596 %somestr = getelementptr [11 x i8]* @somestr3, i64 0, i64 0 ; [#uses=1]
597 ret i8* %somestr
598 }
599
600 define i8* @yetanotherfunc(i32, double) {
601 ret i8* null
602 }
603
604 define i32 @negativeUnsigned() {
605 ret i32 -1
606 }
607
608 define i32 @largeSigned() {
609 ret i32 -394967296
610 }
611 ; ModuleID = 'testlogical.ll'
612
613 define i32 @simpleAdd(i32 %i0, i32 %j0) {
614 %t1 = xor i32 %i0, %j0 ; [#uses=1]
615 %t2 = or i32 %i0, %j0 ; [#uses=1]
616 %t3 = and i32 %t1, %t2 ; [#uses=1]
617 ret i32 %t3
618 }
619 ; ModuleID = 'testmemory.ll'
620 %complexty = type { i32, { [4 x i8*], float }, double }
621 %struct = type { i32, { float, { i8 } }, i64 }
622
623 define i32 @main6() {
624 call i32 @testfunction98( i64 0, i64 1 )
625 ret i32 0
626 }
627
628 define i32 @testfunction98(i64 %i0, i64 %j0) {
629 %array0 = malloc [4 x i8] ; <[4 x i8]*> [#uses=2]
630 %size = add i32 2, 2 ; [#uses=1]
631 %array1 = malloc i8, i32 4 ; [#uses=1]
632 %array2 = malloc i8, i32 %size ; [#uses=1]
633 %idx = getelementptr [4 x i8]* %array0, i64 0, i64 2 ; [#uses=1]
634 store i8 123, i8* %idx
635 free [4 x i8]* %array0
636 free i8* %array1
637 free i8* %array2
638 %aa = alloca %complexty, i32 5 ; <%complexty*> [#uses=1]
639 %idx2 = getelementptr %complexty* %aa, i64 %i0, i32 1, i32 0, i64 %j0 ; [#uses=1]
640 store i8* null, i8** %idx2
641 %ptr = alloca i32 ; [#uses=2]
642 store i32 3, i32* %ptr
643 %val = load i32* %ptr ; [#uses=0]
644 %sptr = alloca %struct ; <%struct*> [#uses=1]
645 %ubsptr = getelementptr %struct* %sptr, i64 0, i32 1, i32 1 ; <{ i8 }*> [#uses=1]
646 %idx3 = getelementptr { i8 }* %ubsptr, i64 0, i32 0 ; [#uses=1]
647 store i8 4, i8* %idx3
648 ret i32 3
649 }
650 ; ModuleID = 'testswitch.ll'
651 %int = type i32
652
653 define i32 @squared(i32 %i0) {
654 switch i32 %i0, label %Default [
655 i32 1, label %Case1
656 i32 2, label %Case2
657 i32 4, label %Case4
658 ]
659
660 Default: ; preds = %0
661 ret i32 -1
662
663 Case1: ; preds = %0
664 ret i32 1
665
666 Case2: ; preds = %0
667 ret i32 4
668
669 Case4: ; preds = %0
670 ret i32 16
671 }
672 ; ModuleID = 'testvarargs.ll'
673
674 declare i32 @printf(i8*, ...)
675
676 define i32 @testvarar() {
677 call i32 (i8*, ...)* @printf( i8* null, i32 12, i8 42 ) ; :1 [#uses=1]
678 ret i32 %1
679 }
680 ; ModuleID = 'undefined.ll'
681 @X2 = global i32 undef ; [#uses=0]
682
683 declare i32 @atoi(i8*)
684
685 define i32 @test1009() {
686 ret i32 undef
687 }
688
689 define i32 @test1003() {
690 %X = add i32 undef, 1 ; [#uses=1]
691 ret i32 %X
692 }
693 ; ModuleID = 'unreachable.ll'
694
695 declare void @bar()
696
697 define i32 @foo1021() {
698 unreachable
699 }
700
701 define double @xyz() {
702 call void @bar( )
703 unreachable
704 }
705 ; ModuleID = 'varargs.ll'
706
707 declare void @llvm.va_start(i8* %ap)
708
709 declare void @llvm.va_copy(i8* %aq, i8* %ap)
710
711 declare void @llvm.va_end(i8* %ap)
712
713 define i32 @test1010(i32 %X, ...) {
714 %ap = alloca i8* ; [#uses=4]
715 %va.upgrd.1 = bitcast i8** %ap to i8* ; [#uses=1]
716 call void @llvm.va_start( i8* %va.upgrd.1 )
717 %tmp = va_arg i8** %ap, i32 ; [#uses=1]
718 %aq = alloca i8* ; [#uses=2]
719 %va0.upgrd.2 = bitcast i8** %aq to i8* ; [#uses=1]
720 %va1.upgrd.3 = bitcast i8** %ap to i8* ; [#uses=1]
721 call void @llvm.va_copy( i8* %va0.upgrd.2, i8* %va1.upgrd.3 )
722 %va.upgrd.4 = bitcast i8** %aq to i8* ; [#uses=1]
723 call void @llvm.va_end( i8* %va.upgrd.4 )
724 %va.upgrd.5 = bitcast i8** %ap to i8* ; [#uses=1]
725 call void @llvm.va_end( i8* %va.upgrd.5 )
726 ret i32 %tmp
727 }
728 ; ModuleID = 'varargs_new.ll'
729
730 declare void @llvm.va_start(i8*)
731
732 declare void @llvm.va_copy(i8*, i8*)
733
734 declare void @llvm.va_end(i8*)
735
736 define i32 @test1011(i32 %X, ...) {
737 %ap = alloca i8* ; [#uses=4]
738 %aq = alloca i8* ; [#uses=2]
739 %va.upgrd.1 = bitcast i8** %ap to i8* ; [#uses=1]
740 call void @llvm.va_start( i8* %va.upgrd.1 )
741 %tmp = va_arg i8** %ap, i32 ; [#uses=1]
742 %apv = load i8** %ap ; [#uses=1]
743 %va0.upgrd.2 = bitcast i8** %aq to i8* ; [#uses=1]
744 %va1.upgrd.3 = bitcast i8* %apv to i8* ; [#uses=1]
745 call void @llvm.va_copy( i8* %va0.upgrd.2, i8* %va1.upgrd.3 )
746 %va.upgrd.4 = bitcast i8** %aq to i8* ; [#uses=1]
747 call void @llvm.va_end( i8* %va.upgrd.4 )
748 %va.upgrd.5 = bitcast i8** %ap to i8* ; [#uses=1]
749 call void @llvm.va_end( i8* %va.upgrd.5 )
750 ret i32 %tmp
751 }
752 ; ModuleID = 'weirdnames.ll'
753 "&^ " = type { i32 }
754 @"%.*+ foo" = global "&^ " { i32 5 } ; <"&^ "*> [#uses=0]
755 @"0" = global float 0.000000e+00 ; [#uses=0]
+0
-7
test/Other/2007-06-16-Funcname.ll less more
None ; RUN: llvm-as < %s | llc -march=cpp -cppfname=WAKKA | not grep makeLLVMModule
1 ; PR1515
2
3 define void @foo() {
4 ret void
5 }
6