diff options
author | Jan Voung <jvoung@chromium.org> | 2012-12-14 15:24:01 -0800 |
---|---|---|
committer | Jan Voung <jvoung@chromium.org> | 2012-12-14 15:24:01 -0800 |
commit | 855bdd0fcc0bdab848ef02860d0225a7780ac9d1 (patch) | |
tree | beb9b72ba6218caa2e677a3d2c84fb1d21c808de | |
parent | e64e31f908ef4e0d2361cacf94c4e513d826c3e1 (diff) |
FastIsel: Get PIC-style GV loads for NaCl64 even w/out 64-bit pointers.
Without this, the load would not be RIP relative, and will end up
being relative to 0, which is R15.
BUG= http://code.google.com/p/nativeclient/issues/detail?id=3219
TEST= ./scons bitcode=1 pnacl_generate_pexe=0 \
run_stack_frame_noopt_noframe_test \
run_unwind_trace_noopt_noframe_test \
run_stack_frame_noopt_frame_test \
run_unwind_trace_noopt_frame_test \
platform=x86-64 nacl_pic=1
Review URL: https://codereview.chromium.org/11575042
-rw-r--r-- | lib/Target/X86/X86FastISel.cpp | 8 | ||||
-rw-r--r-- | test/CodeGen/X86/fast-isel-x86-64.ll | 11 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index f7222841bf..8e415c7d19 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -637,6 +637,14 @@ bool X86FastISel::X86SelectAddress(const Value *V, X86AddressMode &AM) { if (Subtarget->isPICStyleRIPRel()) StubAM.Base.Reg = X86::RIP; + // @LOCALMOD-BEGIN + } else if (Subtarget->isTargetNaCl64()) { + Opc = X86::MOV32rm; + RC = &X86::GR32RegClass; + + if (Subtarget->isPICStyleRIPRel()) + StubAM.Base.Reg = X86::RIP; + // @LOCALMOD-END } else { Opc = X86::MOV32rm; RC = &X86::GR32RegClass; diff --git a/test/CodeGen/X86/fast-isel-x86-64.ll b/test/CodeGen/X86/fast-isel-x86-64.ll index 4800743a5f..86b6606779 100644 --- a/test/CodeGen/X86/fast-isel-x86-64.ll +++ b/test/CodeGen/X86/fast-isel-x86-64.ll @@ -1,6 +1,7 @@ ; RUN: llc < %s -mattr=-avx -fast-isel -O0 -regalloc=fast -asm-verbose=0 -fast-isel-abort | FileCheck %s ; RUN: llc < %s -mattr=+avx -fast-isel -O0 -regalloc=fast -asm-verbose=0 -fast-isel-abort | FileCheck %s --check-prefix=AVX ; RUN: llc < %s -fast-isel -O0 -regalloc=fast -asm-verbose=0 -fast-isel-abort -mtriple=x86_64-none-nacl | FileCheck %s --check-prefix=NACL64 +; RUN: llc < %s -fast-isel -O0 -regalloc=fast -asm-verbose=0 -fast-isel-abort -mtriple=x86_64-none-nacl -relocation-model=pic | FileCheck %s --check-prefix=NACL64_PIC target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-apple-darwin10.0.0" @@ -47,6 +48,16 @@ define i64 @test3() nounwind { ; CHECK-NEXT: ret } +; NACL64 version uses i32 for 32-bit pointers. +define i32 @test3_nacl64() nounwind { + %A = ptrtoint i32* @G to i32 + ret i32 %A + +; NACL64_PIC: test3_nacl64: +; NACL64_PIC: movl G@GOTPCREL(%rip), %eax +; NACL64_PIC-NEXT: popq %rcx +; NACL64_PIC-NEXT: nacljmp %ecx, %r15 +} ; rdar://9289558 |