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