From 647cc93d6ee10b744f3084975e626329a6932c47 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Wed, 23 Mar 2011 19:43:59 +0000 Subject: [PATCH] Revert r128156 because of CodeGenObjC/messages.m and Coverage/codegen-gnu.m. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128157 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGObjCGNU.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 99132d6967..dc91ec764c 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -521,12 +521,9 @@ llvm::Value *CGObjCGNU::GetSelector(CGBuilderTy &Builder, Selector Sel, Types.push_back(TypedSelector(TypeEncoding, SelValue)); } - if (lval) { - llvm::Value *tmp = Builder.CreateAlloca(SelValue->getType()); - Builder.CreateStore(SelValue, tmp); - return tmp; - } - return SelValue; + if (lval) + return SelValue; + return Builder.CreateLoad(SelValue); } llvm::Value *CGObjCGNU::GetSelector(CGBuilderTy &Builder, Selector Sel, @@ -1909,12 +1906,16 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { llvm::Constant *Idxs[] = {Zeros[0], llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), i), Zeros[0]}; // FIXME: We're generating redundant loads and stores here! - llvm::Constant *SelPtr = llvm::ConstantExpr::getGetElementPtr(SelectorList, - Idxs, 2); + llvm::Constant *SelPtr = new llvm::GlobalVariable(TheModule, SelStructPtrTy, + true, llvm::GlobalValue::InternalLinkage, + llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2), + ".objc_sel_ptr"); // If selectors are defined as an opaque type, cast the pointer to this // type. - SelPtr = llvm::ConstantExpr::getBitCast(SelPtr, + if (isSelOpaque) { + SelPtr = llvm::ConstantExpr::getBitCast(SelPtr, llvm::PointerType::getUnqual(SelectorTy)); + } SelectorAliases[i]->replaceAllUsesWith(SelPtr); SelectorAliases[i]->eraseFromParent(); } -- 2.40.0