[llvm] r221386 - [x86 fast-isel] Materialize allocas with the correct-sized lea for ILP32

Derek Schuff dschuff at google.com
Wed Nov 5 11:27:22 PST 2014


Author: dschuff
Date: Wed Nov  5 13:27:21 2014
New Revision: 221386

URL: http://llvm.org/viewvc/llvm-project?rev=221386&view=rev
Log:
[x86 fast-isel] Materialize allocas with the correct-sized lea for ILP32

Summary:
X86FastISel::fastMaterializeAlloca was incorrectly conditioning its
opcode selection on subtarget bitness rather than pointer size.

Differential Revision: http://reviews.llvm.org/D6136

Added:
    llvm/trunk/test/CodeGen/X86/fast-isel-x32.ll
Modified:
    llvm/trunk/lib/Target/X86/X86FastISel.cpp
    llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll

Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=221386&r1=221385&r2=221386&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Wed Nov  5 13:27:21 2014
@@ -3271,7 +3271,7 @@ unsigned X86FastISel::fastMaterializeAll
   X86AddressMode AM;
   if (!X86SelectAddress(C, AM))
     return 0;
-  unsigned Opc = Subtarget->is64Bit() ? X86::LEA64r : X86::LEA32r;
+  unsigned Opc = TLI.getPointerTy() == MVT::i32 ? X86::LEA32r : X86::LEA64r;
   const TargetRegisterClass* RC = TLI.getRegClassFor(TLI.getPointerTy());
   unsigned ResultReg = createResultReg(RC);
   addFullAddress(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,

Added: llvm/trunk/test/CodeGen/X86/fast-isel-x32.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x32.ll?rev=221386&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel-x32.ll (added)
+++ llvm/trunk/test/CodeGen/X86/fast-isel-x32.ll Wed Nov  5 13:27:21 2014
@@ -0,0 +1,14 @@
+; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -fast-isel -fast-isel-abort -regalloc=fast | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-nacl -fast-isel -fast-isel-abort -regalloc=fast | FileCheck %s
+
+; Test that alloca addresses are materialized with the right size instruction.
+
+declare void @bar(i32* %arg)
+
+; CHECK-LABEL: @foo
+define void @foo() {
+  %a = alloca i32
+; CHECK: leal {{.*}}, %edi
+  call void @bar(i32* %a)
+  ret void
+}

Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll?rev=221386&r1=221385&r2=221386&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Wed Nov  5 13:27:21 2014
@@ -302,3 +302,13 @@ define void @test23(i8* noalias sret %re
 }
 
 declare i8* @foo23()
+
+declare void @takesi32ptr(i32* %arg)
+
+; CHECK-LABEL: allocamaterialize
+define void @allocamaterialize() {
+  %a = alloca i32
+; CHECK: leaq {{.*}}, %rdi
+  call void @takesi32ptr(i32* %a)
+  ret void
+}





More information about the llvm-commits mailing list