[llvm] r214614 - [ARM] In dynamic-no-pic mode, ARM's post-RA pseudo expansion was incorrectly
Akira Hatanaka
ahatanaka at apple.com
Fri Aug 1 22:40:41 PDT 2014
Author: ahatanak
Date: Sat Aug 2 00:40:40 2014
New Revision: 214614
URL: http://llvm.org/viewvc/llvm-project?rev=214614&view=rev
Log:
[ARM] In dynamic-no-pic mode, ARM's post-RA pseudo expansion was incorrectly
expanding pseudo LOAD_STATCK_GUARD using instructions that are normally used
in pic mode. This patch fixes the bug.
<rdar://problem/17886592>
Modified:
llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp
llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp
llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp
llvm/trunk/test/CodeGen/ARM/stack_guard_remat.ll
llvm/trunk/test/CodeGen/Thumb/stack_guard_remat.ll
llvm/trunk/test/CodeGen/Thumb2/stack_guard_remat.ll
Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=214614&r1=214613&r2=214614&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Sat Aug 2 00:40:40 2014
@@ -92,10 +92,10 @@ unsigned ARMInstrInfo::getUnindexedOpcod
void ARMInstrInfo::expandLoadStackGuard(MachineBasicBlock::iterator MI,
Reloc::Model RM) const {
- if (RM == Reloc::Static)
- expandLoadStackGuardBase(MI, ARM::LDRLIT_ga_abs, ARM::LDRi12, RM);
- else
+ if (RM == Reloc::PIC_)
expandLoadStackGuardBase(MI, ARM::LDRLIT_ga_pcrel, ARM::LDRi12, RM);
+ else
+ expandLoadStackGuardBase(MI, ARM::LDRLIT_ga_abs, ARM::LDRi12, RM);
}
namespace {
Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp?rev=214614&r1=214613&r2=214614&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Sat Aug 2 00:40:40 2014
@@ -105,8 +105,8 @@ loadRegFromStackSlot(MachineBasicBlock &
void
Thumb1InstrInfo::expandLoadStackGuard(MachineBasicBlock::iterator MI,
Reloc::Model RM) const {
- if (RM == Reloc::Static)
- expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_abs, ARM::tLDRi, RM);
- else
+ if (RM == Reloc::PIC_)
expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_pcrel, ARM::tLDRi, RM);
+ else
+ expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_abs, ARM::tLDRi, RM);
}
Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=214614&r1=214613&r2=214614&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Sat Aug 2 00:40:40 2014
@@ -212,10 +212,10 @@ loadRegFromStackSlot(MachineBasicBlock &
void
Thumb2InstrInfo::expandLoadStackGuard(MachineBasicBlock::iterator MI,
Reloc::Model RM) const {
- if (RM == Reloc::Static)
- expandLoadStackGuardBase(MI, ARM::t2MOVi32imm, ARM::t2LDRi12, RM);
- else
+ if (RM == Reloc::PIC_)
expandLoadStackGuardBase(MI, ARM::t2MOV_ga_pcrel, ARM::t2LDRi12, RM);
+ else
+ expandLoadStackGuardBase(MI, ARM::t2MOVi32imm, ARM::t2LDRi12, RM);
}
void llvm::emitT2RegPlusImmediate(MachineBasicBlock &MBB,
Modified: llvm/trunk/test/CodeGen/ARM/stack_guard_remat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/stack_guard_remat.ll?rev=214614&r1=214613&r2=214614&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/stack_guard_remat.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/stack_guard_remat.ll Sat Aug 2 00:40:40 2014
@@ -1,5 +1,6 @@
; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC
-; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=STATIC
+; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=NO-PIC -check-prefix=STATIC
+; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=dynamic-no-pic -no-integrated-as | FileCheck %s -check-prefix=NO-PIC -check-prefix=DYNAMIC-NO-PIC
;PIC: foo2
;PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
@@ -11,13 +12,17 @@
;PIC: [[LABEL0]]:
;PIC-NEXT: .long L___stack_chk_guard$non_lazy_ptr-([[LABEL1]]+8)
-;STATIC: foo2
-;STATIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
-;STATIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
+;NO-PIC: foo2
+;NO-PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
+;NO-PIC-NOT: LPC
+;NO-PIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
;STATIC: [[LABEL0]]:
;STATIC-NEXT: .long ___stack_chk_guard
+;DYNAMIC-NO-PIC: [[LABEL0]]:
+;DYNAMIC-NO-PIC-NEXT: .long L___stack_chk_guard$non_lazy_ptr
+
; Function Attrs: nounwind ssp
define i32 @test_stack_guard_remat() #0 {
%a1 = alloca [256 x i32], align 4
Modified: llvm/trunk/test/CodeGen/Thumb/stack_guard_remat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/stack_guard_remat.ll?rev=214614&r1=214613&r2=214614&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Thumb/stack_guard_remat.ll (original)
+++ llvm/trunk/test/CodeGen/Thumb/stack_guard_remat.ll Sat Aug 2 00:40:40 2014
@@ -1,5 +1,6 @@
; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC
-; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=STATIC
+; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=NO-PIC -check-prefix=STATIC
+; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=dynamic-no-pic -no-integrated-as | FileCheck %s -check-prefix=NO-PIC -check-prefix=DYNAMIC-NO-PIC
;PIC: foo2
;PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
@@ -11,13 +12,17 @@
;PIC: [[LABEL0]]:
;PIC-NEXT: .long L___stack_chk_guard$non_lazy_ptr-([[LABEL1]]+4)
-;STATIC: foo2
-;STATIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
-;STATIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
+;NO-PIC: foo2
+;NO-PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
+;NO-PIC-NOT: LPC
+;NO-PIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
;STATIC: [[LABEL0]]:
;STATIC-NEXT: .long ___stack_chk_guard
+;DYNAMIC-NO-PIC: [[LABEL0]]:
+;DYNAMIC-NO-PIC-NEXT: .long L___stack_chk_guard$non_lazy_ptr
+
; Function Attrs: nounwind ssp
define i32 @test_stack_guard_remat() #0 {
%a1 = alloca [256 x i32], align 4
Modified: llvm/trunk/test/CodeGen/Thumb2/stack_guard_remat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/stack_guard_remat.ll?rev=214614&r1=214613&r2=214614&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Thumb2/stack_guard_remat.ll (original)
+++ llvm/trunk/test/CodeGen/Thumb2/stack_guard_remat.ll Sat Aug 2 00:40:40 2014
@@ -1,5 +1,6 @@
; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC
; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=STATIC
+; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=dynamic-no-pic -no-integrated-as | FileCheck %s -check-prefix=DYNAMIC-NO-PIC
;PIC: foo2
;PIC: movw [[R0:r[0-9]+]], :lower16:(L___stack_chk_guard$non_lazy_ptr-([[LABEL0:LPC[0-9_]+]]+4))
@@ -14,6 +15,11 @@
;STATIC: movt [[R0]], :upper16:___stack_chk_guard
;STATIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
+;DYNAMIC-NO-PIC: foo2
+;DYNAMIC-NO-PIC: movw [[R0:r[0-9]+]], :lower16:L___stack_chk_guard$non_lazy_ptr
+;DYNAMIC-NO-PIC: movt [[R0]], :upper16:L___stack_chk_guard$non_lazy_ptr
+;DYNAMIC-NO-PIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
+
; Function Attrs: nounwind ssp
define i32 @test_stack_guard_remat() #0 {
%a1 = alloca [256 x i32], align 4
More information about the llvm-commits
mailing list