diff options
author | Hans Wennborg <hans@hanshq.net> | 2014-06-04 21:04:54 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2014-06-04 21:04:54 +0000 |
commit | 8e873329a1dbe298a861f79a0696fdb64f9cc25f (patch) | |
tree | ad7b7a20cbdf44c853de6c124f731808cacbc4e3 /llvm/lib/CodeGen | |
parent | adc9037b88e16c231879f9bfb76e6e3d3003398f (diff) | |
download | bcm5719-llvm-8e873329a1dbe298a861f79a0696fdb64f9cc25f.tar.gz bcm5719-llvm-8e873329a1dbe298a861f79a0696fdb64f9cc25f.zip |
Don't emit structors for available_externally globals (PR19933)
We would previously assert here when trying to figure out the section
for the global.
This makes us handle the situation more gracefully since the IR isn't
malformed.
Differential Revision: http://reviews.llvm.org/D4022
llvm-svn: 210215
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 6c6d0dae9e7..49c2ee20c20 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1349,9 +1349,14 @@ void AsmPrinter::EmitXXStructorList(const Constant *List, bool isCtor) { const TargetLoweringObjectFile &Obj = getObjFileLowering(); const MCSymbol *KeySym = nullptr; const MCSection *KeySec = nullptr; - if (S.ComdatKey) { - KeySym = getSymbol(S.ComdatKey); - KeySec = getObjFileLowering().SectionForGlobal(S.ComdatKey, *Mang, TM); + if (GlobalValue *GV = S.ComdatKey) { + if (GV->hasAvailableExternallyLinkage()) + // If the associated variable is available_externally, some other TU + // will provide its dynamic initializer. + continue; + + KeySym = getSymbol(GV); + KeySec = getObjFileLowering().SectionForGlobal(GV, *Mang, TM); } const MCSection *OutputSection = (isCtor ? Obj.getStaticCtorSection(S.Priority, KeySym, KeySec) |