1 ; RUN: %lli_mcjit -remote-mcjit -O0 -disable-lazy-compilation=false %s 2 ; XFAIL: arm, mips 3 4 ; The intention of this test is to verify that symbols mapped to COMMON in ELF 5 ; work as expected. 6 ; 7 ; Compiled from this C code: 8 ; 9 ; int zero_int; 10 ; double zero_double; 11 ; int zero_arr[10]; 12 ; 13 ; int main() 14 ; { 15 ; zero_arr[zero_int + 5] = 40; 16 ; 17 ; if (zero_double < 1.0) 18 ; zero_arr[zero_int + 2] = 70; 19 ; 20 ; for (int i = 1; i < 10; ++i) { 21 ; zero_arr[i] = zero_arr[i - 1] + zero_arr[i]; 22 ; } 23 ; return zero_arr[9] == 110 ? 0 : -1; 24 ; } 25 26 @zero_int = common global i32 0, align 4 27 @zero_arr = common global [10 x i32] zeroinitializer, align 16 28 @zero_double = common global double 0.000000e+00, align 8 29 30 define i32 @main() nounwind { 31 entry: 32 %retval = alloca i32, align 4 33 %i = alloca i32, align 4 34 store i32 0, i32* %retval 35 %0 = load i32* @zero_int, align 4 36 %add = add nsw i32 %0, 5 37 %idxprom = sext i32 %add to i64 38 %arrayidx = getelementptr inbounds [10 x i32]* @zero_arr, i32 0, i64 %idxprom 39 store i32 40, i32* %arrayidx, align 4 40 %1 = load double* @zero_double, align 8 41 %cmp = fcmp olt double %1, 1.000000e+00 42 br i1 %cmp, label %if.then, label %if.end 43 44 if.then: ; preds = %entry 45 %2 = load i32* @zero_int, align 4 46 %add1 = add nsw i32 %2, 2 47 %idxprom2 = sext i32 %add1 to i64 48 %arrayidx3 = getelementptr inbounds [10 x i32]* @zero_arr, i32 0, i64 %idxprom2 49 store i32 70, i32* %arrayidx3, align 4 50 br label %if.end 51 52 if.end: ; preds = %if.then, %entry 53 store i32 1, i32* %i, align 4 54 br label %for.cond 55 56 for.cond: ; preds = %for.inc, %if.end 57 %3 = load i32* %i, align 4 58 %cmp4 = icmp slt i32 %3, 10 59 br i1 %cmp4, label %for.body, label %for.end 60 61 for.body: ; preds = %for.cond 62 %4 = load i32* %i, align 4 63 %sub = sub nsw i32 %4, 1 64 %idxprom5 = sext i32 %sub to i64 65 %arrayidx6 = getelementptr inbounds [10 x i32]* @zero_arr, i32 0, i64 %idxprom5 66 %5 = load i32* %arrayidx6, align 4 67 %6 = load i32* %i, align 4 68 %idxprom7 = sext i32 %6 to i64 69 %arrayidx8 = getelementptr inbounds [10 x i32]* @zero_arr, i32 0, i64 %idxprom7 70 %7 = load i32* %arrayidx8, align 4 71 %add9 = add nsw i32 %5, %7 72 %8 = load i32* %i, align 4 73 %idxprom10 = sext i32 %8 to i64 74 %arrayidx11 = getelementptr inbounds [10 x i32]* @zero_arr, i32 0, i64 %idxprom10 75 store i32 %add9, i32* %arrayidx11, align 4 76 br label %for.inc 77 78 for.inc: ; preds = %for.body 79 %9 = load i32* %i, align 4 80 %inc = add nsw i32 %9, 1 81 store i32 %inc, i32* %i, align 4 82 br label %for.cond 83 84 for.end: ; preds = %for.cond 85 %10 = load i32* getelementptr inbounds ([10 x i32]* @zero_arr, i32 0, i64 9), align 4 86 %cmp12 = icmp eq i32 %10, 110 87 %cond = select i1 %cmp12, i32 0, i32 -1 88 ret i32 %cond 89 } 90