From: Tim Northover Date: Wed, 10 Dec 2014 23:40:50 +0000 (+0000) Subject: ARM: correctly expand LDR-lit based globals. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=19734e7811cfa345a2ef1909cfc2f60ca3728797;p=oota-llvm.git ARM: correctly expand LDR-lit based globals. Quite a major error here: the expansions for the Pseudos with and without folded load were mixed up. Fortunately it only affects ARM-mode, when not using movw/movt, on Darwin. I'm guessing no-one actually uses that combination. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223986 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/ARM/ARMExpandPseudoInsts.cpp b/lib/Target/ARM/ARMExpandPseudoInsts.cpp index 2d805185e6c..3e8705452aa 100644 --- a/lib/Target/ARM/ARMExpandPseudoInsts.cpp +++ b/lib/Target/ARM/ARMExpandPseudoInsts.cpp @@ -980,7 +980,7 @@ bool ARMExpandPseudo::ExpandMI(MachineBasicBlock &MBB, unsigned LDRLITOpc = IsARM ? ARM::LDRi12 : ARM::tLDRpci; unsigned PICAddOpc = IsARM - ? (Opcode == ARM::LDRLIT_ga_pcrel_ldr ? ARM::PICADD : ARM::PICLDR) + ? (Opcode == ARM::LDRLIT_ga_pcrel_ldr ? ARM::PICLDR : ARM::PICADD) : ARM::tPICADD; // We need a new const-pool entry to load from. diff --git a/lib/Target/ARM/ARMInstrInfo.td b/lib/Target/ARM/ARMInstrInfo.td index bc804206a61..12be8fb469f 100644 --- a/lib/Target/ARM/ARMInstrInfo.td +++ b/lib/Target/ARM/ARMInstrInfo.td @@ -5315,6 +5315,7 @@ def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr), (ARMWrapperPIC tglobaladdr:$addr))]>, Requires<[IsARM, DontUseMovt]>; +let AddedComplexity = 10 in def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr), NoItinerary, [(set GPR:$dst, diff --git a/test/CodeGen/ARM/cse-ldrlit.ll b/test/CodeGen/ARM/cse-ldrlit.ll index ea8c0ca8560..3f5d4c2e3c2 100644 --- a/test/CodeGen/ARM/cse-ldrlit.ll +++ b/test/CodeGen/ARM/cse-ldrlit.ll @@ -33,8 +33,8 @@ false: ; CHECK-ARM-PIC-LABEL: foo: ; CHECK-ARM-PIC: ldr [[VAR_OFFSET:r[0-9]+]], LCPI0_0 ; CHECK-ARM-PIC: LPC0_0: -; CHECK-ARM-PIC-NEXT: ldr r0, [pc, [[VAR_OFFSET]]] -; CHECK-ARM-PIC: ldr {{r[1-9][0-9]?}}, [r0, #4] +; CHECK-ARM-PIC-NEXT: add r0, pc, [[VAR_OFFSET]] +; CHECK-ARM-PIC: ldr {{r[0-9]+}}, [r0, #4] ; CHECK-ARM-PIC: LCPI0_0: ; CHECK-ARM-PIC-NEXT: .long _var-(LPC0_0+8) diff --git a/test/CodeGen/ARM/globals.ll b/test/CodeGen/ARM/globals.ll index 3101500f2ca..2c599bf011a 100644 --- a/test/CodeGen/ARM/globals.ll +++ b/test/CodeGen/ARM/globals.ll @@ -43,6 +43,7 @@ define i32 @test1() { ; DarwinPIC: LPC0_0: ; DarwinPIC: ldr r0, [pc, r0] ; DarwinPIC: ldr r0, [r0] +; DarwinPIC-NOT: ldr ; DarwinPIC: bx lr ; DarwinPIC: .align 2 diff --git a/test/CodeGen/ARM/stack_guard_remat.ll b/test/CodeGen/ARM/stack_guard_remat.ll index b11ea92b04d..7c89b99b8f9 100644 --- a/test/CodeGen/ARM/stack_guard_remat.ll +++ b/test/CodeGen/ARM/stack_guard_remat.ll @@ -8,7 +8,7 @@ ;PIC: foo2 ;PIC: ldr [[R0:r[0-9]+]], [[LABEL0:LCPI[0-9_]+]] ;PIC: [[LABEL1:LPC0_1]]: -;PIC: ldr [[R1:r[0-9]+]], [pc, [[R0]]] +;PIC: add [[R1:r[0-9]+]], pc, [[R0]] ;PIC: ldr [[R2:r[0-9]+]], {{\[}}[[R1]]{{\]}} ;PIC: ldr {{r[0-9]+}}, {{\[}}[[R2]]{{\]}}