1Pull r200368 from upstream llvm trunk (by Venkatraman Govindaraju): 2 3 [SparcV9] Use correct register class (I64RegClass) to hold the address of _GLOBAL_OFFSET_TABLE_ in sparcv9. 4 5Introduced here: http://svnweb.freebsd.org/changeset/base/262261 6 7Index: lib/Target/Sparc/SparcInstrInfo.cpp 8=================================================================== 9--- lib/Target/Sparc/SparcInstrInfo.cpp 10+++ lib/Target/Sparc/SparcInstrInfo.cpp 11@@ -431,9 +431,10 @@ unsigned SparcInstrInfo::getGlobalBaseReg(MachineF 12 MachineBasicBlock::iterator MBBI = FirstMBB.begin(); 13 MachineRegisterInfo &RegInfo = MF->getRegInfo(); 14 15- GlobalBaseReg = RegInfo.createVirtualRegister(&SP::IntRegsRegClass); 16+ const TargetRegisterClass *PtrRC = 17+ Subtarget.is64Bit() ? &SP::I64RegsRegClass : &SP::IntRegsRegClass; 18+ GlobalBaseReg = RegInfo.createVirtualRegister(PtrRC); 19 20- 21 DebugLoc dl; 22 23 BuildMI(FirstMBB, MBBI, dl, get(SP::GETPCX), GlobalBaseReg); 24Index: lib/Target/Sparc/SparcInstrInfo.td 25=================================================================== 26--- lib/Target/Sparc/SparcInstrInfo.td 27+++ lib/Target/Sparc/SparcInstrInfo.td 28@@ -180,7 +180,7 @@ def tlscall : SDNode<"SPISD::TLS_CALL", SDT_ 29 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 30 SDNPVariadic]>; 31 32-def getPCX : Operand<i32> { 33+def getPCX : Operand<iPTR> { 34 let PrintMethod = "printGetPCX"; 35 } 36 37Index: test/CodeGen/SPARC/2009-08-28-PIC.ll 38=================================================================== 39--- test/CodeGen/SPARC/2009-08-28-PIC.ll 40+++ test/CodeGen/SPARC/2009-08-28-PIC.ll 41@@ -1,9 +1,45 @@ 42-; RUN: llc -march=sparc --relocation-model=pic < %s | grep _GLOBAL_OFFSET_TABLE_ 43+; RUN: llc -march=sparc --relocation-model=pic < %s | FileCheck %s --check-prefix=V8 44+; RUN: llc -march=sparcv9 --relocation-model=pic < %s | FileCheck %s --check-prefix=V9 45+; RUN: llc -march=sparc --relocation-model=pic < %s -O0 | FileCheck %s --check-prefix=V8UNOPT 46+; RUN: llc -march=sparcv9 --relocation-model=pic < %s -O0 | FileCheck %s --check-prefix=V9UNOPT 47 48+ 49+; V8-LABEL: func 50+; V8: _GLOBAL_OFFSET_TABLE_ 51+ 52+; V9-LABEL: func 53+; V9: _GLOBAL_OFFSET_TABLE_ 54+ 55 @foo = global i32 0 ; <i32*> [#uses=1] 56 57-define i32 @func() nounwind readonly { 58+define i32 @func(i32 %a) nounwind readonly { 59 entry: 60 %0 = load i32* @foo, align 4 ; <i32> [#uses=1] 61 ret i32 %0 62 } 63+ 64+; V8UNOPT-LABEL: test_spill 65+; V8UNOPT: sethi %hi(_GLOBAL_OFFSET_TABLE_+{{.+}}), [[R:%[goli][0-7]]] 66+; V8UNOPT: or [[R]], %lo(_GLOBAL_OFFSET_TABLE_+{{.+}}), [[R]] 67+; V8UNOPT: add [[R]], %o7, [[R]] 68+; V8UNOPT: st [[R]], [%fp+{{.+}}] 69+ 70+; V9UNOPT-LABEL: test_spill 71+; V9UNOPT: sethi %hi(_GLOBAL_OFFSET_TABLE_+{{.+}}), [[R:%[goli][0-7]]] 72+; V9UNOPT: or [[R]], %lo(_GLOBAL_OFFSET_TABLE_+{{.+}}), [[R]] 73+; V9UNOPT: add [[R]], %o7, [[R]] 74+; V9UNOPT: stx [[R]], [%fp+{{.+}}] 75+ 76+define i32 @test_spill(i32 %a, i32 %b) { 77+entry: 78+ %cmp = icmp eq i32 %b, 0 79+ br i1 %cmp, label %if.then, label %if.end 80+ 81+if.then: 82+ %ret = load i32* @foo, align 4 83+ ret i32 %ret 84+ 85+if.end: 86+ %add = add nsw i32 %b, %a 87+ ret i32 %add 88+} 89