summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2008-04-18 23:43:57 +0000
committerNate Begeman <natebegeman@mac.com>2008-04-18 23:43:57 +0000
commit7fab578b0dae4ea8c30e611bcdf2222e287aec90 (patch)
treee85e647ba59ad2d2e77c0f71d53c1284af649adb /clang/lib/CodeGen/CodeGenModule.cpp
parent46bd037c07d2e8e39adbb9b229d588dd7052980d (diff)
downloadbcm5719-llvm-7fab578b0dae4ea8c30e611bcdf2222e287aec90.tar.gz
bcm5719-llvm-7fab578b0dae4ea8c30e611bcdf2222e287aec90.zip
Add support to module codegen for adding and emitting annotations
llvm-svn: 49944
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index cb34fb5a731..a5a51b19c79 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/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!
OpenPOWER on IntegriCloud