summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-06-24 17:01:28 +0000
committerChris Lattner <sabre@nondot.org>2008-06-24 17:01:28 +0000
commit6447ed3a1fe685546c5a950b6b745007df509678 (patch)
treea6f165b34754742b1e64a404ed92b01184a93e61 /clang/lib/CodeGen
parent17ae57faa8da08e6245ca12c84ac9ca3b97fe853 (diff)
downloadbcm5719-llvm-6447ed3a1fe685546c5a950b6b745007df509678.tar.gz
bcm5719-llvm-6447ed3a1fe685546c5a950b6b745007df509678.zip
"This is a small fix for a bug where static object instances were being incorrectly generated. The bug was caused by my inability to read the GNU libobjc source and is only apparent when JITing code (static compilation does not expose the bug due to the data layout of other globals)."
Patch by David Chisnall! llvm-svn: 52680
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGObjCGNU.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index f2cfdcab82f..2f02b13ee6c 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -755,10 +755,12 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
llvm::StructType::get(PtrToInt8Ty, StaticsArrayTy, NULL);
llvm::Constant *Statics =
MakeGlobal(StaticsListTy, Elements, ".objc_statics");
- Statics = new
- llvm::GlobalVariable(llvm::PointerType::getUnqual(StaticsListTy), false,
- llvm::GlobalValue::InternalLinkage, Statics, ".objc_statics_ptr",
- &TheModule);
+ llvm::ArrayType *StaticsListArrayTy =
+ llvm::ArrayType::get(llvm::PointerType::getUnqual(StaticsListTy), 2);
+ Elements.clear();
+ Elements.push_back(Statics);
+ Elements.push_back(llvm::ConstantPointerNull::get(llvm::PointerType::getUnqual(StaticsListTy)));
+ Statics = MakeGlobal(StaticsListArrayTy, Elements, ".objc_statics_ptr");
Statics = llvm::ConstantExpr::getBitCast(Statics, PtrTy);
// Array of classes, categories, and constant objects
llvm::ArrayType *ClassListTy = llvm::ArrayType::get(PtrToInt8Ty,
OpenPOWER on IntegriCloud