1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
; RUN: pnacl-llc -O2 -mtriple=x86_64-none-nacl < %s | \
; RUN: FileCheck %s --check-prefix=NACLON
; RUN: pnacl-llc -O2 -mtriple=x86_64-linux < %s | \
; RUN: FileCheck %s --check-prefix=NACLOFF
; This test is derived from the following C code:
;
; int myglobal[100];
; void test(int arg)
; {
; myglobal[arg] = arg;
; myglobal[arg+1] = arg;
; }
; int main(int argc, char **argv)
; {
; test(argc);
; }
;
; The goal is NOT to produce an instruction with "myglobal" as the
; displacement value in any addressing mode, e.g. this (bad) instruction:
;
; movl %eax, %nacl:myglobal(%r15,%rax,4)
;
; The NACLOFF test is a canary that tries to ensure that the NACLON test is
; testing the right thing. If the NACLOFF test starts failing, it's likely
; that the LLVM -O2 optimizations are no longer generating the problematic
; pattern that NACLON tests for. In that case, the test should be modified.
@myglobal = global [100 x i32] zeroinitializer, align 4
define void @test(i32 %arg) #0 {
entry:
; NACLON: test:
; NACLON-NOT: mov{{.*}}nacl:myglobal(
; NACLOFF: test:
; NACLOFF: mov{{.*}}myglobal(
%arg.addr = alloca i32, align 4
store i32 %arg, i32* %arg.addr, align 4
%0 = load i32* %arg.addr, align 4
%1 = load i32* %arg.addr, align 4
%arrayidx = getelementptr inbounds [100 x i32]* @myglobal, i32 0, i32 %1
store i32 %0, i32* %arrayidx, align 4
%2 = load i32* %arg.addr, align 4
%3 = load i32* %arg.addr, align 4
%add = add nsw i32 %3, 1
%arrayidx1 = getelementptr inbounds [100 x i32]* @myglobal, i32 0, i32 %add
store i32 %2, i32* %arrayidx1, align 4
ret void
}
|