diff options
author | Robert Lytton <robert@xmos.com> | 2014-07-03 09:30:33 +0000 |
---|---|---|
committer | Robert Lytton <robert@xmos.com> | 2014-07-03 09:30:33 +0000 |
commit | 57765d53477910de18f8c5e7d2ce585a0f782935 (patch) | |
tree | dd49e005a177b84fd5bc0e17927d1c5402bd18a2 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 5b88f78f7a342d1eee97acff4dcc4c0170464535 (diff) | |
download | llvm-57765d53477910de18f8c5e7d2ce585a0f782935.zip llvm-57765d53477910de18f8c5e7d2ce585a0f782935.tar.gz llvm-57765d53477910de18f8c5e7d2ce585a0f782935.tar.bz2 |
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e1ff948..2f840dd 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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")) { |