From: Michael Kuperstein Date: Wed, 21 Jan 2015 14:44:05 +0000 (+0000) Subject: [x32] Fast ISel should use LEA64_32r instead of LEA32r to adjust addresses in x32... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ada9fa1ca93e407f0f5211c0bdf1c338de997937;p=platform%2Fupstream%2Fllvm.git [x32] Fast ISel should use LEA64_32r instead of LEA32r to adjust addresses in x32 mode. llvm-svn: 226661 --- diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index 5d71eac..2269f3f 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 0000000..7ccb34d --- /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 +}