[cfe-commits] r128156 - /cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

David Chisnall csdavec at swan.ac.uk
Wed Mar 23 11:39:12 PDT 2011


Author: theraven
Date: Wed Mar 23 13:39:12 2011
New Revision: 128156

URL: http://llvm.org/viewvc/llvm-project?rev=128156&view=rev
Log:
Remove the redundant loads / stores to globals that we were generating for selectors (GNU runtimes).


Modified:
    cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=128156&r1=128155&r2=128156&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Wed Mar 23 13:39:12 2011
@@ -521,9 +521,12 @@
     Types.push_back(TypedSelector(TypeEncoding, SelValue));
   }
 
-  if (lval)
-    return SelValue;
-  return Builder.CreateLoad(SelValue);
+  if (lval) {
+    llvm::Value *tmp = Builder.CreateAlloca(SelValue->getType());
+    Builder.CreateStore(SelValue, tmp);
+    return tmp;
+  }
+  return SelValue;
 }
 
 llvm::Value *CGObjCGNU::GetSelector(CGBuilderTy &Builder, Selector Sel,
@@ -1906,16 +1909,12 @@
     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 = new llvm::GlobalVariable(TheModule, SelStructPtrTy,
-      true, llvm::GlobalValue::InternalLinkage,
-      llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2),
-      ".objc_sel_ptr");
+    llvm::Constant *SelPtr = llvm::ConstantExpr::getGetElementPtr(SelectorList,
+        Idxs, 2);
     // If selectors are defined as an opaque type, cast the pointer to this
     // type.
-    if (isSelOpaque) {
-      SelPtr = llvm::ConstantExpr::getBitCast(SelPtr,
+    SelPtr = llvm::ConstantExpr::getBitCast(SelPtr,
         llvm::PointerType::getUnqual(SelectorTy));
-    }
     SelectorAliases[i]->replaceAllUsesWith(SelPtr);
     SelectorAliases[i]->eraseFromParent();
   }





More information about the cfe-commits mailing list