• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: %lli -remote-mcjit -O0 -disable-lazy-compilation=false -mcjit-remote-process=lli-child-target%exeext %s
2; XFAIL: mingw32,win32
3; UNSUPPORTED: powerpc64-unknown-linux-gnu
4; Remove UNSUPPORTED for powerpc64-unknown-linux-gnu if problem caused by r266663 is fixed
5
6; The intention of this test is to verify that symbols mapped to COMMON in ELF
7; work as expected.
8;
9; Compiled from this C code:
10;
11; int zero_int;
12; double zero_double;
13; int zero_arr[10];
14;
15; int main()
16; {
17;     zero_arr[zero_int + 5] = 40;
18;
19;     if (zero_double < 1.0)
20;         zero_arr[zero_int + 2] = 70;
21;
22;     for (int i = 1; i < 10; ++i) {
23;         zero_arr[i] = zero_arr[i - 1] + zero_arr[i];
24;     }
25;     return zero_arr[9] == 110 ? 0 : -1;
26; }
27
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
31
32define i32 @main() nounwind {
33entry:
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
45
46if.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
52  br label %if.end
53
54if.end:                                           ; preds = %if.then, %entry
55  store i32 1, i32* %i, align 4
56  br label %for.cond
57
58for.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
62
63for.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
78  br label %for.inc
79
80for.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
84  br label %for.cond
85
86for.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
90  ret i32 %cond
91}
92