diff options
author | Martin Storsjo <martin@martin.st> | 2018-07-25 18:35:31 +0000 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2018-07-25 18:35:31 +0000 |
commit | d2662c32fbb8ded38cd48fea954aea66864eb37d (patch) | |
tree | e87ac8e2141e3d070e91315f39fda174c3d3b3be /llvm/lib/Target | |
parent | f55b8c6e91b54a6d4a48187c4f897c8bf157c215 (diff) | |
download | bcm5719-llvm-d2662c32fbb8ded38cd48fea954aea66864eb37d.tar.gz bcm5719-llvm-d2662c32fbb8ded38cd48fea954aea66864eb37d.zip |
[COFF] Hoist constant pool handling from X86AsmPrinter into AsmPrinter
In SVN r334523, the first half of comdat constant pool handling was
hoisted from X86WindowsTargetObjectFile (which despite the name only
was used for msvc targets) into the arch independent
TargetLoweringObjectFileCOFF, but the other half of the handling was
left behind in X86AsmPrinter::GetCPISymbol.
With only half of the handling in place, inconsistent comdat
sections/symbols are created, causing issues with both GNU binutils
(avoided for X86 in SVN r335918) and with the MS linker, which
would complain like this:
fatal error LNK1143: invalid or corrupt file: no symbol for COMDAT section 0x4
Differential Revision: https://reviews.llvm.org/D49644
llvm-svn: 337950
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Target/ARM/ARMAsmPrinter.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/Target/ARM/ARMAsmPrinter.h | 4 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86AsmPrinter.cpp | 23 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86AsmPrinter.h | 3 |
5 files changed, 13 insertions, 30 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index f5ee0c46c07..52819dedc23 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -242,9 +242,7 @@ MCSymbol *AArch64AsmPrinter::GetCPISymbol(unsigned CPID) const { Twine(getDataLayout().getLinkerPrivateGlobalPrefix()) + "CPI" + Twine(getFunctionNumber()) + "_" + Twine(CPID)); - return OutContext.getOrCreateSymbol( - Twine(getDataLayout().getPrivateGlobalPrefix()) + "CPI" + - Twine(getFunctionNumber()) + "_" + Twine(CPID)); + return AsmPrinter::GetCPISymbol(CPID); } void AArch64AsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNum, diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp index 2412b25eaad..2196f9b47f3 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -235,6 +235,15 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum, } } +MCSymbol *ARMAsmPrinter::GetCPISymbol(unsigned CPID) const { + // The AsmPrinter::GetCPISymbol superclass method tries to use CPID as + // indexes in MachineConstantPool, which isn't in sync with indexes used here. + const DataLayout &DL = getDataLayout(); + return OutContext.getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + + "CPI" + Twine(getFunctionNumber()) + "_" + + Twine(CPID)); +} + //===--------------------------------------------------------------------===// MCSymbol *ARMAsmPrinter:: diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.h b/llvm/lib/Target/ARM/ARMAsmPrinter.h index 7b811b18f74..50f3edeb4e5 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.h +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.h @@ -101,7 +101,9 @@ public: void EmitEndOfAsmFile(Module &M) override; void EmitXXStructor(const DataLayout &DL, const Constant *CV) override; void EmitGlobalVariable(const GlobalVariable *GV) override; - + + MCSymbol *GetCPISymbol(unsigned CPID) const; + // lowerOperand - Convert a MachineOperand into the equivalent MCOperand. bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp); diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp index b779fa03fa0..7d8f7b9dfe4 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -608,29 +608,6 @@ void X86AsmPrinter::EmitStartOfAsmFile(Module &M) { OutStreamer->EmitAssemblerFlag(MCAF_Code16); } -MCSymbol *X86AsmPrinter::GetCPISymbol(unsigned CPID) const { - if (Subtarget->isTargetKnownWindowsMSVC()) { - const MachineConstantPoolEntry &CPE = - MF->getConstantPool()->getConstants()[CPID]; - if (!CPE.isMachineConstantPoolEntry()) { - const DataLayout &DL = MF->getDataLayout(); - SectionKind Kind = CPE.getSectionKind(&DL); - const Constant *C = CPE.Val.ConstVal; - unsigned Align = CPE.Alignment; - if (const MCSectionCOFF *S = dyn_cast<MCSectionCOFF>( - getObjFileLowering().getSectionForConstant(DL, Kind, C, Align))) { - if (MCSymbol *Sym = S->getCOMDATSymbol()) { - if (Sym->isUndefined()) - OutStreamer->EmitSymbolAttribute(Sym, MCSA_Global); - return Sym; - } - } - } - } - - return AsmPrinter::GetCPISymbol(CPID); -} - static void emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel, MachineModuleInfoImpl::StubValueTy &MCSym) { diff --git a/llvm/lib/Target/X86/X86AsmPrinter.h b/llvm/lib/Target/X86/X86AsmPrinter.h index 3a20a9362de..55abdf2ba60 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.h +++ b/llvm/lib/Target/X86/X86AsmPrinter.h @@ -130,9 +130,6 @@ public: unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) override; - /// Return the symbol for the specified constant pool entry. - MCSymbol *GetCPISymbol(unsigned CPID) const override; - bool doInitialization(Module &M) override { SMShadowTracker.reset(0); SM.reset(); |