From e084c0112431574348824a060e9826b41f075573 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 16 Feb 2009 22:25:49 +0000 Subject: [PATCH] fix volatile handling with ExtVectorElementExpr, so that we emit two volatile loads for: typedef __attribute__(( ext_vector_type(4) )) float float4; float test(volatile float4 *P) { return P->x+P->y; } llvm-svn: 64683 --- clang/lib/CodeGen/CGExpr.cpp | 15 +++++++-------- clang/lib/CodeGen/CGValue.h | 8 ++++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 01a5514d6e1d..4dc8a9e1d4d2 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -813,7 +813,7 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) { if (Base.isSimple()) { llvm::Constant *CV = GenerateConstantVector(Indices); return LValue::MakeExtVectorElt(Base.getAddress(), CV, - E->getBase()->getType().getCVRQualifiers()); + Base.getQualifiers()); } assert(Base.isExtVectorElt() && "Can only subscript lvalue vec elts here!"); @@ -828,7 +828,7 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) { } llvm::Constant *CV = llvm::ConstantVector::get(&CElts[0], CElts.size()); return LValue::MakeExtVectorElt(Base.getExtVectorAddr(), CV, - E->getBase()->getType().getCVRQualifiers()); + Base.getQualifiers()); } LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { @@ -846,16 +846,14 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { if (PTy->getPointeeType()->isUnionType()) isUnion = true; CVRQualifiers = PTy->getPointeeType().getCVRQualifiers(); - } - else if (BaseExpr->getStmtClass() == Expr::ObjCPropertyRefExprClass || - BaseExpr->getStmtClass() == Expr::ObjCKVCRefExprClass) { + } else if (isa(BaseExpr) || + isa(BaseExpr)) { RValue RV = EmitObjCPropertyGet(BaseExpr); BaseValue = RV.getAggregateAddr(); if (BaseExpr->getType()->isUnionType()) isUnion = true; CVRQualifiers = BaseExpr->getType().getCVRQualifiers(); - } - else { + } else { LValue BaseLV = EmitLValue(BaseExpr); if (BaseLV.isObjCIvar()) isIvar = true; @@ -869,7 +867,8 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { FieldDecl *Field = dyn_cast(E->getMemberDecl()); // FIXME: Handle non-field member expressions assert(Field && "No code generation for non-field member references"); - LValue MemExpLV = EmitLValueForField(BaseValue, Field, isUnion, CVRQualifiers); + LValue MemExpLV = EmitLValueForField(BaseValue, Field, isUnion, + CVRQualifiers); LValue::SetObjCIvar(MemExpLV, isIvar); return MemExpLV; } diff --git a/clang/lib/CodeGen/CGValue.h b/clang/lib/CodeGen/CGValue.h index dbd9dadb14ed..318ee55ac974 100644 --- a/clang/lib/CodeGen/CGValue.h +++ b/clang/lib/CodeGen/CGValue.h @@ -169,6 +169,10 @@ public: bool isVolatileQualified() const { return Volatile; } bool isRestrictQualified() const { return Restrict; } + unsigned getQualifiers() const { + return (Volatile ? QualType::Volatile : 0) | + (Restrict ? QualType::Restrict : 0); + } bool isObjCIvar() const { return Ivar; } bool isObjCWeak() const { return ObjCType == Weak; } @@ -275,8 +279,8 @@ public: SetQualifiers(Qualifiers,R); return R; } - static LValue MakeKVCRef(const ObjCKVCRefExpr *E, - unsigned Qualifiers) { + + static LValue MakeKVCRef(const ObjCKVCRefExpr *E, unsigned Qualifiers) { LValue R; R.LVType = KVCRef; R.KVCRefExpr = E;