Add support to module codegen for adding and emitting annotations
llvm-svn: 49944
This commit is contained in:
@@ -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!
|
||||
|
||||
Reference in New Issue
Block a user