summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp14
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h7
2 files changed, 15 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index e1ff9485a80..2f840dd182e 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")) {
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 88f5faf7093..c0bfb4c5e6b 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -349,8 +349,8 @@ class CodeGenModule : public CodeGenTypeCache {
/// emitted when the translation unit is complete.
CtorList GlobalDtors;
- /// A map of canonical GlobalDecls to their mangled names.
- llvm::DenseMap<GlobalDecl, StringRef> MangledDeclNames;
+ /// An ordered map of canonical GlobalDecls to their mangled names.
+ llvm::MapVector<GlobalDecl, StringRef> MangledDeclNames;
llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> Manglings;
/// Global annotations.
@@ -1146,6 +1146,9 @@ private:
/// \brief Emit the Clang version as llvm.ident metadata.
void EmitVersionIdentMetadata();
+ /// Emits target specific Metadata for global declarations.
+ void EmitTargetMetadata();
+
/// Emit the llvm.gcov metadata used to tell LLVM where to emit the .gcno and
/// .gcda files in a way that persists in .bc files.
void EmitCoverageFile();
OpenPOWER on IntegriCloud