diff options
author | Nate Begeman <natebegeman@mac.com> | 2008-04-18 23:43:57 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2008-04-18 23:43:57 +0000 |
commit | 532485cc6c078d9e51b517c6bbd8984deb17f0fe (patch) | |
tree | 74107fce19cbbb2af6774cf4e2338796f62e5c25 /lib/CodeGen/CodeGenModule.cpp | |
parent | d6595fa87cd031dab36c6dbb723ae19e822ab2aa (diff) |
Add support to module codegen for adding and emitting annotations
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49944 91177308-0d34-0410-b5e6-96231b3b80d8
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! |