Add support to module codegen for adding and emitting annotations
llvm-svn: 49944
This commit is contained in:
parent
46bd037c07
commit
7fab578b0d
|
@ -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!
|
||||
|
|
|
@ -59,6 +59,7 @@ class CodeGenModule {
|
|||
llvm::Function *MemSetFn;
|
||||
llvm::DenseMap<const Decl*, llvm::Constant*> GlobalDeclMap;
|
||||
std::vector<llvm::Constant*> GlobalCtors;
|
||||
std::vector<llvm::Constant*> Annotations;
|
||||
|
||||
llvm::StringMap<llvm::Constant*> CFConstantStringMap;
|
||||
llvm::StringMap<llvm::Constant*> ConstantStringMap;
|
||||
|
@ -99,6 +100,8 @@ public:
|
|||
|
||||
void AddGlobalCtor(llvm::Function * Ctor);
|
||||
void EmitGlobalCtors(void);
|
||||
void AddAnnotation(llvm::Constant *C) { Annotations.push_back(C); }
|
||||
void EmitAnnotations(void);
|
||||
|
||||
void EmitObjCMethod(const ObjCMethodDecl *OMD);
|
||||
void EmitFunction(const FunctionDecl *FD);
|
||||
|
|
Loading…
Reference in New Issue