]> granicus.if.org Git - clang/commitdiff
Revert r128156 because of CodeGenObjC/messages.m and Coverage/codegen-gnu.m.
authorAndrew Trick <atrick@apple.com>
Wed, 23 Mar 2011 19:43:59 +0000 (19:43 +0000)
committerAndrew Trick <atrick@apple.com>
Wed, 23 Mar 2011 19:43:59 +0000 (19:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128157 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCGNU.cpp

index 99132d6967c93f478f3bdc2934b56b012c1d44c5..dc91ec764ca2f5efa7490ce308b820eb6b87d007 100644 (file)
@@ -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();
   }