From 4c388b2c9d263a2c348d926a45548d6caad5e3df Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 9 Jul 2009 05:47:33 +0000 Subject: [PATCH] make isel use MO_PIC_BASE_OFFSET when lowering globalvalues on darwin in pic mode, instead of having asmprinter just "know" to print them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75109 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 8 ++------ lib/Target/X86/X86ISelLowering.cpp | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index ede0fa98e8f..66e926aa228 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -445,21 +445,17 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, else { HiddenGVStubs.insert(Name); printSuffixedName(Name, "$non_lazy_ptr"); - assert(MO.getTargetFlags() == 0); + //assert(MO.getTargetFlags() == 0 || MO_PIC_BASE_OFFSET); } } else { GVStubs.insert(Name); printSuffixedName(Name, "$non_lazy_ptr"); - assert(MO.getTargetFlags() == 0); + //assert(MO.getTargetFlags() == 0 || MO_PIC_BASE_OFFSET); } } else { O << Name; } - if (TM.getRelocationModel() == Reloc::PIC_) { - O << '-'; - PrintPICBaseSymbol(); - } } else { O << Name; } diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 45ab8eb66fc..31b18b7e6b3 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -4575,6 +4575,9 @@ X86TargetLowering::LowerGlobalAddress(const GlobalValue *GV, DebugLoc dl, OpFlags = X86II::MO_GOT; else OpFlags = X86II::MO_GOTOFF; + } else if (Subtarget->isPICStyleStub() && + getTargetMachine().getRelocationModel() == Reloc::PIC_) { + OpFlags = X86II::MO_PIC_BASE_OFFSET; } Result = DAG.getTargetGlobalAddress(GV, getPointerTy(), 0, OpFlags);