[cfe-commits] r59645 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CGObjCMac.cpp CGValue.h
Fariborz Jahanian
fjahanian at apple.com
Wed Nov 19 09:34:07 PST 2008
Author: fjahanian
Date: Wed Nov 19 11:34:06 2008
New Revision: 59645
URL: http://llvm.org/viewvc/llvm-project?rev=59645&view=rev
Log:
Few more changes due to Daniel's feedback.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGValue.h
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=59645&r1=59644&r2=59645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Nov 19 11:34:06 2008
@@ -151,7 +151,7 @@
/// 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.ObjcWeak()) {
+ if (LV.isObjCWeak()) {
// load of a __weak object.
llvm::Value *AddrWeakObj = LV.getAddress();
llvm::Value *read_weak = CGM.getObjCRuntime().EmitObjCWeakRead(*this,
@@ -335,22 +335,6 @@
/// is 'Ty'.
void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
QualType Ty) {
- if (Dst.ObjcWeak()) {
- // load of a __weak object.
- llvm::Value *LvalueDst = Dst.getAddress();
- llvm::Value *src = Src.getScalarVal();
- CGM.getObjCRuntime().EmitObjCWeakAssign(*this, src, LvalueDst);
- return;
- }
-
- if (Dst.ObjcStrong()) {
- // load of a __strong object.
- llvm::Value *LvalueDst = Dst.getAddress();
- llvm::Value *src = Src.getScalarVal();
- CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst);
- return;
- }
-
if (!Dst.isSimple()) {
if (Dst.isVectorElt()) {
// Read/modify/write the vector, inserting the new element.
@@ -376,6 +360,22 @@
assert(0 && "Unknown LValue type");
}
+ if (Dst.isObjCWeak()) {
+ // load of a __weak object.
+ llvm::Value *LvalueDst = Dst.getAddress();
+ llvm::Value *src = Src.getScalarVal();
+ CGM.getObjCRuntime().EmitObjCWeakAssign(*this, src, LvalueDst);
+ return;
+ }
+
+ if (Dst.isObjCStrong()) {
+ // load of a __strong object.
+ llvm::Value *LvalueDst = Dst.getAddress();
+ llvm::Value *src = Src.getScalarVal();
+ CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst);
+ return;
+ }
+
llvm::Value *DstAddr = Dst.getAddress();
assert(Src.isScalar() && "Can't emit an agg store with this method");
// FIXME: Handle volatility etc.
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=59645&r1=59644&r2=59645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Nov 19 11:34:06 2008
@@ -1788,6 +1788,7 @@
llvm::Value * CGObjCMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
llvm::Value *AddrWeakObj)
{
+ AddrWeakObj = CGF.Builder.CreateBitCast(AddrWeakObj, ObjCTypes.PtrObjectPtrTy);
llvm::Value *read_weak = CGF.Builder.CreateCall(ObjCTypes.GcReadWeakFn,
AddrWeakObj, "weakread");
return read_weak;
@@ -1799,6 +1800,8 @@
void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dst)
{
+ src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
+ dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
CGF.Builder.CreateCall2(ObjCTypes.GcAssignWeakFn,
src, dst, "weakassign");
return;
@@ -1810,6 +1813,8 @@
void CGObjCMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dst)
{
+ src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
+ dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
CGF.Builder.CreateCall2(ObjCTypes.GcAssignGlobalFn,
src, dst, "globalassign");
return;
@@ -1821,6 +1826,8 @@
void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dst)
{
+ src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
+ dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
CGF.Builder.CreateCall2(ObjCTypes.GcAssignStrongCastFn,
src, dst, "weakassign");
return;
Modified: cfe/trunk/lib/CodeGen/CGValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGValue.h?rev=59645&r1=59644&r2=59645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGValue.h (original)
+++ cfe/trunk/lib/CodeGen/CGValue.h Wed Nov 19 11:34:06 2008
@@ -159,8 +159,8 @@
bool isVolatileQualified() const { return Volatile; }
bool isRestrictQualified() const { return Restrict; }
- bool ObjcWeak() const { return ObjCType == Weak; }
- bool ObjcStrong() const { return ObjCType == Strong; }
+ bool isObjCWeak() const { return ObjCType == Weak; }
+ bool isObjCStrong() const { return ObjCType == Strong; }
static void SetObjCType(unsigned WeakVal, unsigned StrongVal, LValue& R) {
if (WeakVal)
More information about the cfe-commits
mailing list