The LLVM 2.6-compatible IR below is derived from the HLVM test suite and is
one of the things I've noticed going wrong. However, I just discovered that
it works with LLVM 2.6 and with LLVM SVN when run through lli or llc
without -tailcallopt but when I use:
$ llvm-as -f aout.ll
$ llc -tailcallopt -f aout.bc -o aout.s
$ gcc -lm aout.s -o aout
and the latest LLVM SVN it starts to print incorrect output (it is supposed to
print the Mandelbrot set in ASCII). Perhaps this is a repro for the new
TCO-related bug?
; ModuleID = 'aout.bc'
%0 = type { i32, %1 }
%1 = type { i8*, i32, i8*, i8* }
%2 = type { i32 (%1)*, i32 (%1)* }
%3 = type { i32, %1, %0, %1 }
%4 = type { i32, double, double, double, double }
%5 = type { i32, i32, i32 }
%6 = type { i32, i32 }
@buf25 = global [2 x i8] c" \00" ; <[2 x
i8]*> [#uses=1]
@buf26 = global [2 x i8] c".\00" ; <[2 x
i8]*> [#uses=1]
@buf27 = global [2 x i8] c"\0A\00" ; <[2 x
i8]*> [#uses=1]
declare i32 @putchar(i32)
declare void @exit(i32)
declare i32 @printf(i8*, ...)
define fastcc i32 @gc_check() {
ret i32 0
}
define fastcc i32 @pixel(i32, double, double, double, double) {
entry:
br label %start
start: ; preds = %entry
%5 = insertvalue %4 undef, i32 %0, 0 ; <%4> [#uses=1]
%6 = insertvalue %4 %5, double %1, 1 ; <%4> [#uses=1]
%7 = insertvalue %4 %6, double %2, 2 ; <%4> [#uses=1]
%8 = insertvalue %4 %7, double %3, 3 ; <%4> [#uses=1]
%9 = insertvalue %4 %8, double %4, 4 ; <%4> [#uses=0]
%10 = call fastcc i32 @gc_check() ; <i32> [#uses=0]
%11 = icmp eq i32 %0, 65536 ; <i1> [#uses=1]
br i1 %11, label %pass, label %fail
fail: ; preds = %start
%12 = fmul double %1, %1 ; <double> [#uses=1]
%13 = fmul double %2, %2 ; <double> [#uses=1]
%14 = fadd double %12, %13 ; <double> [#uses=1]
%15 = fcmp oge double %14, 4.000000e+00 ; <i1> [#uses=1]
br i1 %15, label %pass2, label %fail1
pass: ; preds = %start
%16 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([2 x i8]*
@buf25, i32 0, i32 0)) ; <i32> [#uses=0]
ret i32 0
fail1: ; preds = %fail
%17 = add i32 %0, 1 ; <i32> [#uses=1]
%18 = fmul double %1, %1 ; <double> [#uses=1]
%19 = fmul double %2, %2 ; <double> [#uses=1]
%20 = fsub double %18, %19 ; <double> [#uses=1]
%21 = fadd double %20, %3 ; <double> [#uses=1]
%22 = fmul double 2.000000e+00, %1 ; <double> [#uses=1]
%23 = fmul double %22, %2 ; <double> [#uses=1]
%24 = fadd double %23, %4 ; <double> [#uses=1]
%25 = tail call fastcc i32 @pixel(i32 %17, double %21, double %24,
double %3, double %4) ; <i32> [#uses=1]
ret i32 %25
pass2: ; preds = %fail
%26 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([2 x i8]*
@buf26, i32 0, i32 0)) ; <i32> [#uses=0]
ret i32 0
}
define fastcc i32 @row(i32, i32, i32) {
entry:
br label %start
start: ; preds = %entry
%3 = insertvalue %5 undef, i32 %0, 0 ; <%5> [#uses=1]
%4 = insertvalue %5 %3, i32 %1, 1 ; <%5> [#uses=1]
%5 = insertvalue %5 %4, i32 %2, 2 ; <%5> [#uses=0]
%6 = call fastcc i32 @gc_check() ; <i32> [#uses=0]
%7 = icmp sgt i32 %0, %2 ; <i1> [#uses=1]
br i1 %7, label %pass, label %fail
fail: ; preds = %start
%8 = sitofp i32 %0 to double ; <double> [#uses=1]
%9 = fmul double 2.000000e+00, %8 ; <double> [#uses=1]
%10 = sitofp i32 %2 to double ; <double> [#uses=1]
%11 = fdiv double %9, %10 ; <double> [#uses=1]
%12 = fsub double %11, 1.500000e+00 ; <double> [#uses=1]
%13 = sitofp i32 %1 to double ; <double> [#uses=1]
%14 = fmul double 2.000000e+00, %13 ; <double> [#uses=1]
%15 = sitofp i32 %2 to double ; <double> [#uses=1]
%16 = fdiv double %14, %15 ; <double> [#uses=1]
%17 = fsub double %16, 1.000000e+00 ; <double> [#uses=1]
%18 = call fastcc i32 @pixel(i32 0, double 0.000000e+00, double
0.000000e+00, double %12, double %17) ; <i32> [#uses=0]
%19 = add i32 %0, 1 ; <i32> [#uses=1]
%20 = tail call fastcc i32 @row(i32 %19, i32 %1, i32 %2) ; <i32>
[#uses=1]
ret i32 %20
pass: ; preds = %start
ret i32 0
}
define fastcc i32 @col(i32, i32) {
entry:
br label %start
start: ; preds = %entry
%2 = insertvalue %6 undef, i32 %0, 0 ; <%6> [#uses=1]
%3 = insertvalue %6 %2, i32 %1, 1 ; <%6> [#uses=0]
%4 = call fastcc i32 @gc_check() ; <i32> [#uses=0]
%5 = icmp sgt i32 %0, %1 ; <i1> [#uses=1]
br i1 %5, label %pass, label %fail
fail: ; preds = %start
%6 = call fastcc i32 @row(i32 0, i32 %0, i32 %1) ; <i32> [#uses=0]
%7 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([2 x i8]*
@buf27, i32 0, i32 0)) ; <i32> [#uses=0]
%8 = add i32 %0, 1 ; <i32> [#uses=1]
%9 = tail call fastcc i32 @col(i32 %8, i32 %1) ; <i32> [#uses=1]
ret i32 %9
pass: ; preds = %start
ret i32 0
}
define i32 @main() {
%1 = call fastcc i32 @col(i32 0, i32 77)
ret i32 0
}
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e