diff options
| -rw-r--r-- | llvm/lib/Target/X86/X86FastISel.cpp | 10 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/x32-lea-1.ll | 10 | 
2 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index 5d71eac7c05..2269f3fa895 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -3224,7 +3224,10 @@ unsigned X86FastISel::X86MaterializeGV(const GlobalValue *GV, MVT VT) {                ResultReg)          .addGlobalAddress(GV);      } else { -      unsigned Opc = TLI.getPointerTy() == MVT::i32 ? X86::LEA32r : X86::LEA64r; +      unsigned Opc = TLI.getPointerTy() == MVT::i32 +                     ? (Subtarget->isTarget64BitILP32() +                        ? X86::LEA64_32r : X86::LEA32r) +                     : X86::LEA64r;        addFullAddress(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,                               TII.get(Opc), ResultReg), AM);      } @@ -3266,7 +3269,10 @@ unsigned X86FastISel::fastMaterializeAlloca(const AllocaInst *C) {    X86AddressMode AM;    if (!X86SelectAddress(C, AM))      return 0; -  unsigned Opc = TLI.getPointerTy() == MVT::i32 ? X86::LEA32r : X86::LEA64r; +  unsigned Opc = TLI.getPointerTy() == MVT::i32 +                 ? (Subtarget->isTarget64BitILP32() +                    ? X86::LEA64_32r : X86::LEA32r) +                 : X86::LEA64r;    const TargetRegisterClass* RC = TLI.getRegClassFor(TLI.getPointerTy());    unsigned ResultReg = createResultReg(RC);    addFullAddress(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, diff --git a/llvm/test/CodeGen/X86/x32-lea-1.ll b/llvm/test/CodeGen/X86/x32-lea-1.ll new file mode 100644 index 00000000000..7ccb34d1dc7 --- /dev/null +++ b/llvm/test/CodeGen/X86/x32-lea-1.ll @@ -0,0 +1,10 @@ +; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -O0 | FileCheck %s +; CHECK: leal {{[-0-9]*}}(%r{{s|b}}p), +; CHECK-NOT: leal {{[-0-9]*}}(%e{{s|b}}p), + +define void @foo(i32** %p) { +  %a = alloca i32, i32 10 +  %addr = getelementptr i32* %a, i32 4 +  store i32* %addr, i32** %p +  ret void +}  | 

