diff options
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index cb34fb5a73..a5a51b19c7 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -44,6 +44,7 @@ CodeGenModule::~CodeGenModule() { if (ObjCInitFunction) AddGlobalCtor(ObjCInitFunction); EmitGlobalCtors(); + EmitAnnotations(); delete Runtime; } @@ -123,6 +124,22 @@ void CodeGenModule::EmitGlobalCtors() { +void CodeGenModule::EmitAnnotations() { + if (Annotations.empty()) + return; + + // Create a new global variable for the ConstantStruct in the Module. + llvm::Constant *Array = + llvm::ConstantArray::get(llvm::ArrayType::get(Annotations[0]->getType(), + Annotations.size()), + Annotations); + llvm::GlobalValue *gv = + new llvm::GlobalVariable(Array->getType(), false, + llvm::GlobalValue::AppendingLinkage, Array, + "llvm.global.annotations", &TheModule); + gv->setSection("llvm.metadata"); +} + /// ReplaceMapValuesWith - This is a really slow and bad function that /// searches for any entries in GlobalDeclMap that point to OldVal, changing /// them to point to NewVal. This is badbadbad, FIXME! |