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