summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
diff options
context:
space:
mode:
authorDaniel Sanders <daniel.sanders@imgtec.com>2016-05-06 14:37:24 +0000
committerDaniel Sanders <daniel.sanders@imgtec.com>2016-05-06 14:37:24 +0000
commit8de3d3cad6d17a0118584ddceaad587c77f869d8 (patch)
tree38a2bafb823759476aaac9de55f6b836752ebfe8 /llvm/lib/Target/Mips/MipsAsmPrinter.cpp
parent2801d32c0740eefaa6ba71a0ab4de16e192c5cdb (diff)
downloadbcm5719-llvm-8de3d3cad6d17a0118584ddceaad587c77f869d8.tar.gz
bcm5719-llvm-8de3d3cad6d17a0118584ddceaad587c77f869d8.zip
[mips] Fix inconsistent .cprestore behaviour between direct object emission and assembling.
Summary: Direct object emission has an initialization order problem where an InitMCObjectFile is called after MipsTargetELFStreamer determines whether PIC is enabled by default or not. There doesn't seem to be point that initializes all cases so split the responsibility between MipsTargetELFStreamer and MipsAsmPrinter. Reviewers: sdardis Subscribers: dsanders, llvm-commits, sdardis Differential Revision: http://reviews.llvm.org/D19728 llvm-svn: 268737
Diffstat (limited to 'llvm/lib/Target/Mips/MipsAsmPrinter.cpp')
-rw-r--r--llvm/lib/Target/Mips/MipsAsmPrinter.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index cd35b0caee5..24afb8863a6 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -669,6 +669,12 @@ printRegisterList(const MachineInstr *MI, int opNum, raw_ostream &O) {
}
void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) {
+ MipsTargetStreamer &TS = getTargetStreamer();
+
+ // MipsTargetStreamer has an initialization order problem when emitting an
+ // object file directly (see MipsTargetELFStreamer for full details). Work
+ // around it by re-initializing the PIC state here.
+ TS.setPic(OutContext.getObjectFileInfo()->getRelocM());
// Compute MIPS architecture attributes based on the default subtarget
// that we'd have constructed. Module level directives aren't LTO
@@ -684,14 +690,14 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) {
bool IsABICalls = STI.isABICalls();
const MipsABIInfo &ABI = MTM.getABI();
if (IsABICalls) {
- getTargetStreamer().emitDirectiveAbiCalls();
+ TS.emitDirectiveAbiCalls();
Reloc::Model RM = TM.getRelocationModel();
// FIXME: This condition should be a lot more complicated that it is here.
// Ideally it should test for properties of the ABI and not the ABI
// itself.
// For the moment, I'm only correcting enough to make MIPS-IV work.
if (RM == Reloc::Static && !ABI.IsN64())
- getTargetStreamer().emitDirectiveOptionPic0();
+ TS.emitDirectiveOptionPic0();
}
// Tell the assembler which ABI we are using
@@ -702,8 +708,8 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) {
// NaN: At the moment we only support:
// 1. .nan legacy (default)
// 2. .nan 2008
- STI.isNaN2008() ? getTargetStreamer().emitDirectiveNaN2008()
- : getTargetStreamer().emitDirectiveNaNLegacy();
+ STI.isNaN2008() ? TS.emitDirectiveNaN2008()
+ : TS.emitDirectiveNaNLegacy();
// TODO: handle O64 ABI
@@ -716,19 +722,19 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) {
ELF::SHT_PROGBITS, 0));
}
- getTargetStreamer().updateABIInfo(STI);
+ TS.updateABIInfo(STI);
// We should always emit a '.module fp=...' but binutils 2.24 does not accept
// it. We therefore emit it when it contradicts the ABI defaults (-mfpxx or
// -mfp64) and omit it otherwise.
if (ABI.IsO32() && (STI.isABI_FPXX() || STI.isFP64bit()))
- getTargetStreamer().emitDirectiveModuleFP();
+ TS.emitDirectiveModuleFP();
// We should always emit a '.module [no]oddspreg' but binutils 2.24 does not
// accept it. We therefore emit it when it contradicts the default or an
// option has changed the default (i.e. FPXX) and omit it otherwise.
if (ABI.IsO32() && (!STI.useOddSPReg() || STI.isABI_FPXX()))
- getTargetStreamer().emitDirectiveModuleOddSPReg();
+ TS.emitDirectiveModuleOddSPReg();
}
void MipsAsmPrinter::emitInlineAsmStart() const {
OpenPOWER on IntegriCloud