Generate objc_read_weak for __weak objc loads.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59553 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 9935625..d537c9c 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -151,6 +151,14 @@
 /// this method emits the address of the lvalue, then loads the result as an
 /// rvalue, returning the rvalue.
 RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
+  if (LV.isObjcWeak()) {
+    // load of a __weak object. 
+    llvm::Value *AddrWeakObj = LV.getAddress();
+    llvm::Value *read_weak = CGM.getObjCRuntime().EmitObjCWeakCall(*this, 
+                                                                   AddrWeakObj);
+    return RValue::get(read_weak);
+  }
+      
   if (LV.isSimple()) {
     llvm::Value *Ptr = LV.getAddress();
     const llvm::Type *EltTy =