/// special global used by LLVM. If so, emit it and return true, otherwise
/// do nothing and return false.
bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
- assert(GV->hasInitializer() && GV->hasAppendingLinkage() &&
- "Not a special LLVM global!");
+ // Ignore debug and non-emitted data.
+ if (GV->getSection() == "llvm.metadata") return true;
+
+ if (!GV->hasAppendingLinkage()) return false;
+
+ assert(GV->hasInitializer() && "Not a special LLVM global!");
if (GV->getName() == "llvm.used")
return true; // No need to emit this at all.
GlobalValue::InternalLinkage,
CA, "llvm.dbg.array",
SR.getModule());
+ CAGV->setSection("llvm.metadata");
Constant *CAE = ConstantExpr::getCast(CAGV, EmptyTy);
Elements.push_back(CAE);
}
GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true,
GlobalVariable::InternalLinkage,
ConstStr, "str", M);
+ StrGV->setSection("llvm.metadata");
// Convert to generic string pointer.
Slot = ConstantExpr::getCast(StrGV, getStrPtrType());
return Slot;
// Create the GlobalVariable early to prevent infinite recursion.
GlobalVariable *GV = new GlobalVariable(Ty, true, DD->getLinkage(),
NULL, DD->getDescString(), M);
+ GV->setSection("llvm.metadata");
// Insert new GlobalVariable in DescGlobals map.
Slot = GV;
if (!I->hasInitializer()) continue; // External global require no code
// Check to see if this is a special global used by LLVM, if so, emit it.
- if (I->hasAppendingLinkage() && EmitSpecialLLVMGlobal(I))
+ if (EmitSpecialLLVMGlobal(I))
continue;
std::string name = Mang->getValueName(I);
if (!I->hasInitializer()) continue; // External global require no code
// Check to see if this is a special global used by LLVM, if so, emit it.
- if (I->hasAppendingLinkage() && EmitSpecialLLVMGlobal(I))
+ if (EmitSpecialLLVMGlobal(I))
continue;
std::string name = Mang->getValueName(I);