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