From 7e7eb8ce695930193a7e6e6a6ad0e0d52d3d97c3 Mon Sep 17 00:00:00 2001 From: Venkatraman Govindaraju Date: Sun, 22 Sep 2013 01:40:24 +0000 Subject: [PATCH] [SPARC] Make functions with GLOBAL_OFFSET_TABLE access as non-leaf functions. llvm-svn: 191160 --- llvm/lib/Target/Sparc/SparcISelLowering.cpp | 4 ++++ llvm/test/CodeGen/SPARC/constpool.ll | 8 ++++++-- llvm/test/CodeGen/SPARC/globals.ll | 10 ++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Target/Sparc/SparcISelLowering.cpp b/llvm/lib/Target/Sparc/SparcISelLowering.cpp index 2260fe48b313..eb9896c1f569 100644 --- a/llvm/lib/Target/Sparc/SparcISelLowering.cpp +++ b/llvm/lib/Target/Sparc/SparcISelLowering.cpp @@ -1651,6 +1651,10 @@ SDValue SparcTargetLowering::makeAddress(SDValue Op, SelectionDAG &DAG) const { SDValue HiLo = makeHiLoPair(Op, SPII::MO_HI, SPII::MO_LO, DAG); SDValue GlobalBase = DAG.getNode(SPISD::GLOBAL_BASE_REG, DL, VT); SDValue AbsAddr = DAG.getNode(ISD::ADD, DL, VT, GlobalBase, HiLo); + // GLOBAL_BASE_REG codegen'ed with call. Inform MFI that this + // function has calls. + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); + MFI->setHasCalls(true); return DAG.getLoad(VT, DL, DAG.getEntryNode(), AbsAddr, MachinePointerInfo::getGOT(), false, false, false, 0); } diff --git a/llvm/test/CodeGen/SPARC/constpool.ll b/llvm/test/CodeGen/SPARC/constpool.ll index d8b7b153ee09..b861676ce3e1 100644 --- a/llvm/test/CodeGen/SPARC/constpool.ll +++ b/llvm/test/CodeGen/SPARC/constpool.ll @@ -39,8 +39,10 @@ entry: ; v8pic32: sethi %hi(.LCPI0_0), %[[R1:[gilo][0-7]]] ; v8pic32: add %[[R1]], %lo(.LCPI0_0), %[[Goffs:[gilo][0-7]]] ; v8pic32: ld [%[[GOT:[gilo][0-7]]]+%[[Goffs]]], %[[Gaddr:[gilo][0-7]]] -; v8pic32: jmp %o7+8 ; v8pic32: ld [%[[Gaddr]]], %f0 +; v8pic32: jmp %i7+8 +; v8pic32: restore + ; v9pic32: floatCP @@ -48,6 +50,8 @@ entry: ; v9pic32: sethi %hi(.LCPI0_0), %[[R1:[gilo][0-7]]] ; v9pic32: add %[[R1]], %lo(.LCPI0_0), %[[Goffs:[gilo][0-7]]] ; v9pic32: ldx [%[[GOT:[gilo][0-7]]]+%[[Goffs]]], %[[Gaddr:[gilo][0-7]]] -; v9pic32: jmp %o7+8 ; v9pic32: ld [%[[Gaddr]]], %f1 +; v9pic32: jmp %i7+8 +; v9pic32: restore + diff --git a/llvm/test/CodeGen/SPARC/globals.ll b/llvm/test/CodeGen/SPARC/globals.ll index 0e0dfc8f8db6..7e3effe3f4ce 100644 --- a/llvm/test/CodeGen/SPARC/globals.ll +++ b/llvm/test/CodeGen/SPARC/globals.ll @@ -41,8 +41,9 @@ define zeroext i8 @loadG() { ; v8pic32: sethi %hi(G), %[[R1:[gilo][0-7]]] ; v8pic32: add %[[R1]], %lo(G), %[[Goffs:[gilo][0-7]]] ; v8pic32: ld [%[[GOT:[gilo][0-7]]]+%[[Goffs]]], %[[Gaddr:[gilo][0-7]]] -; v8pic32: jmp %o7+8 -; v8pic32: ldub [%[[Gaddr]]], %o0 +; v8pic32: ldub [%[[Gaddr]]], %i0 +; v8pic32: jmp %i7+8 +; v8pic32: restore ; v9pic32: loadG @@ -50,6 +51,7 @@ define zeroext i8 @loadG() { ; v9pic32: sethi %hi(G), %[[R1:[gilo][0-7]]] ; v9pic32: add %[[R1]], %lo(G), %[[Goffs:[gilo][0-7]]] ; v9pic32: ldx [%[[GOT:[gilo][0-7]]]+%[[Goffs]]], %[[Gaddr:[gilo][0-7]]] -; v9pic32: jmp %o7+8 -; v9pic32: ldub [%[[Gaddr]]], %o0 +; v9pic32: ldub [%[[Gaddr]]], %i0 +; v9pic32: jmp %i7+8 +; v9pic32: restore