Add support to module codegen for adding and emitting annotations

llvm-svn: 49944
This commit is contained in:
Nate Begeman
2008-04-18 23:43:57 +00:00
parent 46bd037c07
commit 7fab578b0d
2 changed files with 20 additions and 0 deletions

View File

@@ -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!