From 6dc2317b59cb1180a59f6c283d96b7a5dfeb5307 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 18 Nov 2008 21:45:40 +0000 Subject: 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 --- lib/CodeGen/CGExpr.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 993562592b..d537c9ca81 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -151,6 +151,14 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { /// 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 = -- cgit v1.2.3