forked from OSchip/llvm-project
Support generation of objc_assign_ivar for ivar
write-barriers. llvm-svn: 59748
This commit is contained in:
parent
22e9677a5e
commit
75686a58f3
|
@ -372,7 +372,10 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
|
||||||
// load of a __strong object.
|
// load of a __strong object.
|
||||||
llvm::Value *LvalueDst = Dst.getAddress();
|
llvm::Value *LvalueDst = Dst.getAddress();
|
||||||
llvm::Value *src = Src.getScalarVal();
|
llvm::Value *src = Src.getScalarVal();
|
||||||
CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst);
|
if (Dst.isObjCIvar())
|
||||||
|
CGM.getObjCRuntime().EmitObjCIvarAssign(*this, src, LvalueDst);
|
||||||
|
else
|
||||||
|
CGM.getObjCRuntime().EmitObjCGlobalAssign(*this, src, LvalueDst);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +526,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
|
||||||
|
|
||||||
/// SetVarDeclObjCAttribute - Set __weak/__strong attributes into the LValue
|
/// SetVarDeclObjCAttribute - Set __weak/__strong attributes into the LValue
|
||||||
/// object.
|
/// object.
|
||||||
static void SetVarDeclObjCAttribute(ASTContext &Ctx, const VarDecl *VD,
|
static void SetVarDeclObjCAttribute(ASTContext &Ctx, const Decl *VD,
|
||||||
const QualType &Ty, LValue &LV)
|
const QualType &Ty, LValue &LV)
|
||||||
{
|
{
|
||||||
if (const ObjCGCAttr *A = VD->getAttr<ObjCGCAttr>()) {
|
if (const ObjCGCAttr *A = VD->getAttr<ObjCGCAttr>()) {
|
||||||
|
@ -932,7 +935,10 @@ LValue CodeGenFunction::EmitLValueForIvar(llvm::Value *BaseValue,
|
||||||
unsigned Index = CGM.getTypes().getLLVMFieldNo(Ivar);
|
unsigned Index = CGM.getTypes().getLLVMFieldNo(Ivar);
|
||||||
|
|
||||||
llvm::Value *V = Builder.CreateStructGEP(BaseValue, Index, "tmp");
|
llvm::Value *V = Builder.CreateStructGEP(BaseValue, Index, "tmp");
|
||||||
return LValue::MakeAddr(V, Ivar->getType().getCVRQualifiers()|CVRQualifiers);
|
LValue LV = LValue::MakeAddr(V, Ivar->getType().getCVRQualifiers()|CVRQualifiers);
|
||||||
|
SetVarDeclObjCAttribute(getContext(), Ivar, Ivar->getType(), LV);
|
||||||
|
LValue::SetObjCIvar(LV);
|
||||||
|
return LV;
|
||||||
}
|
}
|
||||||
|
|
||||||
LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) {
|
LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) {
|
||||||
|
|
|
@ -137,9 +137,13 @@ class LValue {
|
||||||
// FIXME: set but never used, what effect should it have?
|
// FIXME: set but never used, what effect should it have?
|
||||||
bool Restrict:1;
|
bool Restrict:1;
|
||||||
|
|
||||||
|
// objective-c's ivar
|
||||||
|
bool Ivar:1;
|
||||||
|
|
||||||
// objective-c's gc attributes
|
// objective-c's gc attributes
|
||||||
unsigned ObjCType : 2;
|
unsigned ObjCType : 2;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void SetQualifiers(unsigned Qualifiers, LValue& R) {
|
static void SetQualifiers(unsigned Qualifiers, LValue& R) {
|
||||||
R.Volatile = (Qualifiers&QualType::Volatile)!=0;
|
R.Volatile = (Qualifiers&QualType::Volatile)!=0;
|
||||||
|
@ -147,6 +151,7 @@ private:
|
||||||
// FIXME: Convenient place to set objc flags to 0. This
|
// FIXME: Convenient place to set objc flags to 0. This
|
||||||
// should really be done in a user-defined constructor instead.
|
// should really be done in a user-defined constructor instead.
|
||||||
R.ObjCType = None;
|
R.ObjCType = None;
|
||||||
|
R.Ivar = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -159,9 +164,14 @@ public:
|
||||||
bool isVolatileQualified() const { return Volatile; }
|
bool isVolatileQualified() const { return Volatile; }
|
||||||
bool isRestrictQualified() const { return Restrict; }
|
bool isRestrictQualified() const { return Restrict; }
|
||||||
|
|
||||||
|
bool isObjCIvar() const { return Ivar; }
|
||||||
bool isObjCWeak() const { return ObjCType == Weak; }
|
bool isObjCWeak() const { return ObjCType == Weak; }
|
||||||
bool isObjCStrong() const { return ObjCType == Strong; }
|
bool isObjCStrong() const { return ObjCType == Strong; }
|
||||||
|
|
||||||
|
static void SetObjCIvar(LValue& R) {
|
||||||
|
R.Ivar = true;
|
||||||
|
}
|
||||||
|
|
||||||
static void SetObjCType(bool isWeak, bool isStrong, LValue& R) {
|
static void SetObjCType(bool isWeak, bool isStrong, LValue& R) {
|
||||||
assert(!(isWeak == true && isStrong == true));
|
assert(!(isWeak == true && isStrong == true));
|
||||||
if (isWeak)
|
if (isWeak)
|
||||||
|
|
Loading…
Reference in New Issue