Move the calling of emitTargetMD() later.
Summary:
Because a global created by GetOrCreateLLVMGlobal() is not finalised until later viz:
extern char a[];
char f(){ return a[5];}
char a[10];
Change MangledDeclNames to use a MapVector rather than a DenseMap so that the
Metadata is output in order of original declaration, so to make deterministic
and improve human readablity.
Differential Revision: http://reviews.llvm.org/D4176
llvm-svn: 212263
This commit is contained in:
@@ -393,6 +393,8 @@ void CodeGenModule::Release() {
|
||||
DebugInfo->finalize();
|
||||
|
||||
EmitVersionIdentMetadata();
|
||||
|
||||
EmitTargetMetadata();
|
||||
}
|
||||
|
||||
void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
|
||||
@@ -1534,8 +1536,6 @@ CodeGenModule::GetOrCreateLLVMFunction(StringRef MangledName,
|
||||
}
|
||||
}
|
||||
|
||||
getTargetCodeGenInfo().emitTargetMD(D, F, *this);
|
||||
|
||||
// Make sure the result is of the requested type.
|
||||
if (!IsIncompleteFunction) {
|
||||
assert(F->getType()->getElementType() == Ty);
|
||||
@@ -1685,8 +1685,6 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
|
||||
if (AddrSpace != Ty->getAddressSpace())
|
||||
return llvm::ConstantExpr::getAddrSpaceCast(GV, Ty);
|
||||
|
||||
getTargetCodeGenInfo().emitTargetMD(D, GV, *this);
|
||||
|
||||
return GV;
|
||||
}
|
||||
|
||||
@@ -3340,6 +3338,14 @@ void CodeGenModule::EmitVersionIdentMetadata() {
|
||||
IdentMetadata->addOperand(llvm::MDNode::get(Ctx, IdentNode));
|
||||
}
|
||||
|
||||
void CodeGenModule::EmitTargetMetadata() {
|
||||
for (auto &I : MangledDeclNames) {
|
||||
const Decl *D = I.first.getDecl()->getMostRecentDecl();
|
||||
llvm::GlobalValue *GV = GetGlobalValue(I.second);
|
||||
getTargetCodeGenInfo().emitTargetMD(D, GV, *this);
|
||||
}
|
||||
}
|
||||
|
||||
void CodeGenModule::EmitCoverageFile() {
|
||||
if (!getCodeGenOpts().CoverageFile.empty()) {
|
||||
if (llvm::NamedMDNode *CUNode = TheModule.getNamedMetadata("llvm.dbg.cu")) {
|
||||
|
||||
Reference in New Issue
Block a user