1 Pull r200368 from upstream llvm trunk (by Venkatraman Govindaraju):
3 [SparcV9] Use correct register class (I64RegClass) to hold the address of _GLOBAL_OFFSET_TABLE_ in sparcv9.
5 Introduced here: http://svnweb.freebsd.org/changeset/base/262261
7 Index: 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();
15 - GlobalBaseReg = RegInfo.createVirtualRegister(&SP::IntRegsRegClass);
16 + const TargetRegisterClass *PtrRC =
17 + Subtarget.is64Bit() ? &SP::I64RegsRegClass : &SP::IntRegsRegClass;
18 + GlobalBaseReg = RegInfo.createVirtualRegister(PtrRC);
23 BuildMI(FirstMBB, MBBI, dl, get(SP::GETPCX), GlobalBaseReg);
24 Index: 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,
32 -def getPCX : Operand<i32> {
33 +def getPCX : Operand<iPTR> {
34 let PrintMethod = "printGetPCX";
37 Index: 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
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
50 +; V8: _GLOBAL_OFFSET_TABLE_
53 +; V9: _GLOBAL_OFFSET_TABLE_
55 @foo = global i32 0 ; <i32*> [#uses=1]
57 -define i32 @func() nounwind readonly {
58 +define i32 @func(i32 %a) nounwind readonly {
60 %0 = load i32* @foo, align 4 ; <i32> [#uses=1]
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+{{.+}}]
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+{{.+}}]
76 +define i32 @test_spill(i32 %a, i32 %b) {
78 + %cmp = icmp eq i32 %b, 0
79 + br i1 %cmp, label %if.then, label %if.end
82 + %ret = load i32* @foo, align 4
86 + %add = add nsw i32 %b, %a