llvm.org GIT mirror llvm / 7e55ac7
[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> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214614 91177308-0d34-0410-b5e6-96231b3b80d8 Akira Hatanaka 5 years ago
6 changed file(s) with 33 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
9191
9292 void ARMInstrInfo::expandLoadStackGuard(MachineBasicBlock::iterator MI,
9393 Reloc::Model RM) const {
94 if (RM == Reloc::Static)
94 if (RM == Reloc::PIC_)
95 expandLoadStackGuardBase(MI, ARM::LDRLIT_ga_pcrel, ARM::LDRi12, RM);
96 else
9597 expandLoadStackGuardBase(MI, ARM::LDRLIT_ga_abs, ARM::LDRi12, RM);
96 else
97 expandLoadStackGuardBase(MI, ARM::LDRLIT_ga_pcrel, ARM::LDRi12, RM);
9898 }
9999
100100 namespace {
104104 void
105105 Thumb1InstrInfo::expandLoadStackGuard(MachineBasicBlock::iterator MI,
106106 Reloc::Model RM) const {
107 if (RM == Reloc::Static)
107 if (RM == Reloc::PIC_)
108 expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_pcrel, ARM::tLDRi, RM);
109 else
108110 expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_abs, ARM::tLDRi, RM);
109 else
110 expandLoadStackGuardBase(MI, ARM::tLDRLIT_ga_pcrel, ARM::tLDRi, RM);
111111 }
211211 void
212212 Thumb2InstrInfo::expandLoadStackGuard(MachineBasicBlock::iterator MI,
213213 Reloc::Model RM) const {
214 if (RM == Reloc::Static)
214 if (RM == Reloc::PIC_)
215 expandLoadStackGuardBase(MI, ARM::t2MOV_ga_pcrel, ARM::t2LDRi12, RM);
216 else
215217 expandLoadStackGuardBase(MI, ARM::t2MOVi32imm, ARM::t2LDRi12, RM);
216 else
217 expandLoadStackGuardBase(MI, ARM::t2MOV_ga_pcrel, ARM::t2LDRi12, RM);
218218 }
219219
220220 void llvm::emitT2RegPlusImmediate(MachineBasicBlock &MBB,
0 ; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC
1 ; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=STATIC
1 ; RUN: llc < %s -mtriple=arm-apple-ios -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=NO-PIC -check-prefix=STATIC
2 ; 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
23
34 ;PIC: foo2
45 ;PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
1011 ;PIC: [[LABEL0]]:
1112 ;PIC-NEXT: .long L___stack_chk_guard$non_lazy_ptr-([[LABEL1]]+8)
1213
13 ;STATIC: foo2
14 ;STATIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
15 ;STATIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
14 ;NO-PIC: foo2
15 ;NO-PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
16 ;NO-PIC-NOT: LPC
17 ;NO-PIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
1618
1719 ;STATIC: [[LABEL0]]:
1820 ;STATIC-NEXT: .long ___stack_chk_guard
21
22 ;DYNAMIC-NO-PIC: [[LABEL0]]:
23 ;DYNAMIC-NO-PIC-NEXT: .long L___stack_chk_guard$non_lazy_ptr
1924
2025 ; Function Attrs: nounwind ssp
2126 define i32 @test_stack_guard_remat() #0 {
0 ; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC
1 ; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=STATIC
1 ; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=NO-PIC -check-prefix=STATIC
2 ; 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
23
34 ;PIC: foo2
45 ;PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
1011 ;PIC: [[LABEL0]]:
1112 ;PIC-NEXT: .long L___stack_chk_guard$non_lazy_ptr-([[LABEL1]]+4)
1213
13 ;STATIC: foo2
14 ;STATIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
15 ;STATIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
14 ;NO-PIC: foo2
15 ;NO-PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]]
16 ;NO-PIC-NOT: LPC
17 ;NO-PIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
1618
1719 ;STATIC: [[LABEL0]]:
1820 ;STATIC-NEXT: .long ___stack_chk_guard
21
22 ;DYNAMIC-NO-PIC: [[LABEL0]]:
23 ;DYNAMIC-NO-PIC-NEXT: .long L___stack_chk_guard$non_lazy_ptr
1924
2025 ; Function Attrs: nounwind ssp
2126 define i32 @test_stack_guard_remat() #0 {
0 ; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=pic -no-integrated-as | FileCheck %s -check-prefix=PIC
11 ; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=static -no-integrated-as | FileCheck %s -check-prefix=STATIC
2 ; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=dynamic-no-pic -no-integrated-as | FileCheck %s -check-prefix=DYNAMIC-NO-PIC
23
34 ;PIC: foo2
45 ;PIC: movw [[R0:r[0-9]+]], :lower16:(L___stack_chk_guard$non_lazy_ptr-([[LABEL0:LPC[0-9_]+]]+4))
1213 ;STATIC: movw [[R0:r[0-9]+]], :lower16:___stack_chk_guard
1314 ;STATIC: movt [[R0]], :upper16:___stack_chk_guard
1415 ;STATIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
16
17 ;DYNAMIC-NO-PIC: foo2
18 ;DYNAMIC-NO-PIC: movw [[R0:r[0-9]+]], :lower16:L___stack_chk_guard$non_lazy_ptr
19 ;DYNAMIC-NO-PIC: movt [[R0]], :upper16:L___stack_chk_guard$non_lazy_ptr
20 ;DYNAMIC-NO-PIC: ldr {{r[0-9]+}}, {{\[}}[[R0]]{{\]}}
1521
1622 ; Function Attrs: nounwind ssp
1723 define i32 @test_stack_guard_remat() #0 {