Skip to content

Commit 883fb05

Browse files
committed
Force non-darwin targets to use a static relo model. This fixes PR734,
tested by CodeGen/Generic/vector.ll llvm-svn: 27657
1 parent b88cb09 commit 883fb05

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -805,16 +805,17 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
805805
SDOperand CPI = DAG.getTargetConstantPool(C, MVT::i32, CP->getAlignment());
806806
SDOperand Zero = DAG.getConstant(0, MVT::i32);
807807

808-
if (getTargetMachine().getRelocationModel() == Reloc::Static) {
808+
// If this is a non-darwin platform, we don't support non-static relo models
809+
// yet.
810+
if (getTargetMachine().getRelocationModel() == Reloc::Static ||
811+
!getTargetMachine().getSubtarget<PPCSubtarget>().isDarwin()) {
809812
// Generate non-pic code that has direct accesses to the constant pool.
810813
// The address of the global is just (hi(&g)+lo(&g)).
811814
SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, CPI, Zero);
812815
SDOperand Lo = DAG.getNode(PPCISD::Lo, MVT::i32, CPI, Zero);
813816
return DAG.getNode(ISD::ADD, MVT::i32, Hi, Lo);
814817
}
815818

816-
// Only lower ConstantPool on Darwin.
817-
if (!getTargetMachine().getSubtarget<PPCSubtarget>().isDarwin()) break;
818819
SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, CPI, Zero);
819820
if (getTargetMachine().getRelocationModel() == Reloc::PIC) {
820821
// With PIC, the first instruction is actually "GR+hi(&G)".
@@ -832,17 +833,17 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
832833
SDOperand GA = DAG.getTargetGlobalAddress(GV, MVT::i32, GSDN->getOffset());
833834
SDOperand Zero = DAG.getConstant(0, MVT::i32);
834835

835-
if (getTargetMachine().getRelocationModel() == Reloc::Static) {
836+
// If this is a non-darwin platform, we don't support non-static relo models
837+
// yet.
838+
if (getTargetMachine().getRelocationModel() == Reloc::Static ||
839+
!getTargetMachine().getSubtarget<PPCSubtarget>().isDarwin()) {
836840
// Generate non-pic code that has direct accesses to globals.
837841
// The address of the global is just (hi(&g)+lo(&g)).
838842
SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, GA, Zero);
839843
SDOperand Lo = DAG.getNode(PPCISD::Lo, MVT::i32, GA, Zero);
840844
return DAG.getNode(ISD::ADD, MVT::i32, Hi, Lo);
841845
}
842846

843-
// Only lower GlobalAddress on Darwin.
844-
if (!getTargetMachine().getSubtarget<PPCSubtarget>().isDarwin()) break;
845-
846847
SDOperand Hi = DAG.getNode(PPCISD::Hi, MVT::i32, GA, Zero);
847848
if (getTargetMachine().getRelocationModel() == Reloc::PIC) {
848849
// With PIC, the first instruction is actually "GR+hi(&G)".

0 commit comments

Comments
 (0)