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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210215 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Hans Wennborg
2014-06-04 21:04:54 +00:00
parent cfee6c49ea
commit 6248abf28d
2 changed files with 20 additions and 5 deletions

View File

@@ -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)