aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjCMac.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-06-23 21:47:46 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-06-23 21:47:46 +0000
commitc38e9affd4519ea199af22419c8c794973cc4b23 (patch)
treeb9670dacb0360172c12aff9ba7218814e73ff4a6 /lib/CodeGen/CGObjCMac.cpp
parent2e01cdacc5ecab5a14329405dc481a18ac3ccfdc (diff)
Patch fixes an obscure bug when 'used' attribute is applied to
variables in ObjC's Next runtime mode. Next runtime also implicitly applies 'used' attribute on some of its meta-data. This results in two 'llvm.used' arrays to be generated, and one of them is renamed to 'llvm.used1'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r--lib/CodeGen/CGObjCMac.cpp46
1 files changed, 12 insertions, 34 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 6ffca8134a..325b2ccaa2 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -911,6 +911,8 @@ protected:
const CallArgList &CallArgs,
const ObjCCommonTypesHelper &ObjCTypes);
+ virtual void MergeMetadataGlobals(std::vector<llvm::Constant*> &UsedArray);
+
public:
CGObjCCommonMac(CodeGen::CodeGenModule &cgm) : CGM(cgm)
{ }
@@ -3426,6 +3428,16 @@ void CGObjCCommonMac::GetNameForMethod(const ObjCMethodDecl *D,
NameOut += ']';
}
+void CGObjCCommonMac::MergeMetadataGlobals(
+ std::vector<llvm::Constant*> &UsedArray) {
+ llvm::Type *i8PTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
+ for (std::vector<llvm::GlobalVariable*>::iterator i = UsedGlobals.begin(),
+ e = UsedGlobals.end(); i != e; ++i) {
+ UsedArray.push_back(llvm::ConstantExpr::getBitCast(cast<llvm::Constant>(*i),
+ i8PTy));
+ }
+}
+
void CGObjCMac::FinishModule() {
EmitModuleInfo();
@@ -3447,22 +3459,6 @@ void CGObjCMac::FinishModule() {
Values));
}
- std::vector<llvm::Constant*> Used;
- for (std::vector<llvm::GlobalVariable*>::iterator i = UsedGlobals.begin(),
- e = UsedGlobals.end(); i != e; ++i) {
- Used.push_back(llvm::ConstantExpr::getBitCast(*i, ObjCTypes.Int8PtrTy));
- }
-
- llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.Int8PtrTy, Used.size());
- llvm::GlobalValue *GV =
- new llvm::GlobalVariable(AT, false,
- llvm::GlobalValue::AppendingLinkage,
- llvm::ConstantArray::get(AT, Used),
- "llvm.used",
- &CGM.getModule());
-
- GV->setSection("llvm.metadata");
-
// Add assembler directives to add lazy undefined symbol references
// for classes which are referenced but not defined. This is
// important for correct linker interaction.
@@ -4111,24 +4107,6 @@ void CGObjCNonFragileABIMac::FinishNonFragileABIModule() {
IMGV->setSection("__DATA, __objc_imageinfo, regular, no_dead_strip");
IMGV->setConstant(true);
UsedGlobals.push_back(IMGV);
-
- std::vector<llvm::Constant*> Used;
-
- for (std::vector<llvm::GlobalVariable*>::iterator i = UsedGlobals.begin(),
- e = UsedGlobals.end(); i != e; ++i) {
- Used.push_back(llvm::ConstantExpr::getBitCast(*i, ObjCTypes.Int8PtrTy));
- }
-
- llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.Int8PtrTy, Used.size());
- llvm::GlobalValue *GV =
- new llvm::GlobalVariable(AT, false,
- llvm::GlobalValue::AppendingLinkage,
- llvm::ConstantArray::get(AT, Used),
- "llvm.used",
- &CGM.getModule());
-
- GV->setSection("llvm.metadata");
-
}
/// LegacyDispatchedSelector - Returns true if SEL is not in the list of