r340140 - [NEON] Define fp16 vld and vst intrinsics conditionally
Author: kosarev Date: Sun Aug 19 09:30:57 2018 New Revision: 340140 URL: http://llvm.org/viewvc/llvm-project?rev=340140&view=rev Log: [NEON] Define fp16 vld and vst intrinsics conditionally This patch fixes definitions of vld and vst NEON intrinsics so that we only define them if half-precision arithmetic is supported on the target platform, as prescribed in ACLE 2.0. Differential Revision: https://reviews.llvm.org/D49075 Modified: cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/test/CodeGen/arm-neon-vld.c cfe/trunk/test/CodeGen/arm-neon-vst.c cfe/trunk/test/Sema/arm-no-fp16.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=340140&r1=340139&r2=340140&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Sun Aug 19 09:30:57 2018 @@ -337,48 +337,78 @@ def VSLI_N : WInst<"vsli_n", "dddi", // E.3.14 Loads and stores of a single vector def VLD1 : WInst<"vld1", "dc", - "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">; + "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">; def VLD1_X2 : WInst<"vld1_x2", "2c", - "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; + "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; def VLD1_X3 : WInst<"vld1_x3", "3c", - "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; + "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; def VLD1_X4 : WInst<"vld1_x4", "4c", - "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; + "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; def VLD1_LANE : WInst<"vld1_lane", "dcdi", - "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">; + "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">; def VLD1_DUP : WInst<"vld1_dup", "dc", - "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">; + "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">; def VST1 : WInst<"vst1", "vpd", - "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">; + "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">; def VST1_X2 : WInst<"vst1_x2", "vp2", - "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; + "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; def VST1_X3 : WInst<"vst1_x3", "vp3", - "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; + "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; def VST1_X4 : WInst<"vst1_x4", "vp4", - "cfhilsUcUiUlUsQcQfQhQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; + "cfilsUcUiUlUsQcQfQiQlQsQUcQUiQUlQUsPcPsQPcQPs">; def VST1_LANE : WInst<"vst1_lane", "vpdi", - "QUcQUsQUiQUlQcQsQiQlQhQfQPcQPsUcUsUiUlcsilhfPcPs">; + "QUcQUsQUiQUlQcQsQiQlQfQPcQPsUcUsUiUlcsilfPcPs">; +let ArchGuard = "(__ARM_FP & 2)" in { +def VLD1_F16 : WInst<"vld1", "dc", "hQh">; +def VLD1_X2_F16 : WInst<"vld1_x2", "2c", "hQh">; +def VLD1_X3_F16 : WInst<"vld1_x3", "3c", "hQh">; +def VLD1_X4_F16 : WInst<"vld1_x4", "4c", "hQh">; +def VLD1_LANE_F16 : WInst<"vld1_lane", "dcdi", "hQh">; +def VLD1_DUP_F16 : WInst<"vld1_dup", "dc", "hQh">; +def VST1_F16 : WInst<"vst1", "vpd", "hQh">; +def VST1_X2_F16 : WInst<"vst1_x2", "vp2", "hQh">; +def VST1_X3_F16 : WInst<"vst1_x3", "vp3", "hQh">; +def VST1_X4_F16 : WInst<"vst1_x4", "vp4", "hQh">; +def VST1_LANE_F16 : WInst<"vst1_lane", "vpdi", "hQh">; +} // E.3.15 Loads and stores of an N-element structure -def VLD2 : WInst<"vld2", "2c", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">; -def VLD3 : WInst<"vld3", "3c", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">; -def VLD4 : WInst<"vld4", "4c", "QUcQUsQUiQcQsQiQhQfQPcQPsUcUsUiUlcsilhfPcPs">; +def VLD2 : WInst<"vld2", "2c", "QUcQUsQUiQcQsQiQfQPcQPsUcUsUiUlcsilfPcPs">; +def VLD3 : WInst<"vld3", "3c", "QUcQUsQUiQcQsQiQfQPcQPsUcUsUiUlcsilfPcPs">; +def VLD4 : WInst<"vld4", "4c", "QUcQUsQUiQcQsQiQfQPcQPsUcUsUiUlcsilfPcPs">; def VLD2_DUP : WInst<"vld2_dup", "2c", - "UcUsUiUlcsilhfPcPsQcQfQhQiQlQsQPcQPsQUcQUiQUlQUs">; + "UcUsUiUlcsilfPcPsQcQfQiQlQsQPcQPsQUcQUiQUlQUs">; def VLD3_DUP : WInst<"vld3_dup", "3c", - "UcUsUiUlcsilhfPcPsQcQfQhQiQlQsQPcQPsQUcQUiQUlQUs">; + "UcUsUiUlcsilfPcPsQcQfQiQlQsQPcQPsQUcQUiQUlQUs">; def VLD4_DUP : WInst<"vld4_dup", "4c", - "UcUsUiUlcsilhfPcPsQcQfQhQiQlQsQPcQPsQUcQUiQUlQUs">; -de
r314209 - Fix TBAA information for reference accesses
Author: kosarev Date: Tue Sep 26 07:22:48 2017 New Revision: 314209 URL: http://llvm.org/viewvc/llvm-project?rev=314209&view=rev Log: Fix TBAA information for reference accesses This patch fixes clang to decorate reference accesses as pointers and not as "omnipotent chars". Differential Revision: https://reviews.llvm.org/D38074 Added: cfe/trunk/test/CodeGen/tbaa-reference.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=314209&r1=314208&r2=314209&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Tue Sep 26 07:22:48 2017 @@ -145,10 +145,10 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) { if (Ty->isStdByteType()) return MetadataCache[Ty] = getChar(); - // Handle pointers. + // Handle pointers and references. // TODO: Implement C++'s type "similarity" and consider dis-"similar" // pointers distinct. - if (Ty->isPointerType()) + if (Ty->isPointerType() || Ty->isReferenceType()) return MetadataCache[Ty] = createTBAAScalarType("any pointer", getChar()); Added: cfe/trunk/test/CodeGen/tbaa-reference.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-reference.cpp?rev=314209&view=auto == --- cfe/trunk/test/CodeGen/tbaa-reference.cpp (added) +++ cfe/trunk/test/CodeGen/tbaa-reference.cpp Tue Sep 26 07:22:48 2017 @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s +// +// Check that we generate correct TBAA information for reference accesses. + +struct S; + +struct B { + S &s; + B(S &s) : s(s) {} + void bar(); +}; + +void foo(S &s) { + B b(s); + b.bar(); +} + +// CHECK-LABEL: _Z3fooR1S +// Check initialization of the reference parameter in foo(). +// CHECK: store %struct.S* {{.*}}, %struct.S** {{.*}}, !tbaa [[TAG_pointer:!.*]] +// +// CHECK-LABEL: _ZN1BC2ER1S +// TODO: Check loading of the reference parameter in B::B(S&). +// Check initialization of B::s in B::B(S&). +// CHECK: store %struct.S* {{.*}}, %struct.S** {{.*}}, !tbaa [[TAG_pointer]] +// +// CHECK-DAG: [[TAG_pointer]] = !{[[TYPE_pointer:!.*]], [[TYPE_pointer]], i64 0} +// CHECK-DAG: [[TYPE_pointer]] = !{!"any pointer", [[TYPE_char:!.*]], i64 0} +// CHECK-DAG: [[TYPE_char]] = !{!"omnipotent char", {{!.*}}, i64 0} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314660 - [CodeGen] Have a special function to get TBAA info for may-alias accesses
Author: kosarev Date: Mon Oct 2 04:10:04 2017 New Revision: 314660 URL: http://llvm.org/viewvc/llvm-project?rev=314660&view=rev Log: [CodeGen] Have a special function to get TBAA info for may-alias accesses This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38408 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=314660&r1=314659&r2=314660&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 2 04:10:04 2017 @@ -1522,7 +1522,7 @@ llvm::Value *CodeGenFunction::EmitLoadOf if (TBAAAccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias -? CGM.getTBAATypeInfo(getContext().CharTy) +? CGM.getTBAAMayAliasTypeInfo() : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); if (TBAA) CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias); @@ -1613,7 +1613,7 @@ void CodeGenFunction::EmitStoreOfScalar( if (TBAAAccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias -? CGM.getTBAATypeInfo(getContext().CharTy) +? CGM.getTBAAMayAliasTypeInfo() : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); if (TBAA) CGM.DecorateInstructionWithTBAA(Store, TBAA, MayAlias); @@ -3724,11 +3724,8 @@ LValue CodeGenFunction::EmitLValueForFie // Loading the reference will disable path-aware TBAA. TBAAPath = false; if (CGM.shouldUseTBAA()) { -llvm::MDNode *tbaa; -if (mayAlias) - tbaa = CGM.getTBAATypeInfo(getContext().CharTy); -else - tbaa = CGM.getTBAATypeInfo(type); +llvm::MDNode *tbaa = mayAlias ? CGM.getTBAAMayAliasTypeInfo() : +CGM.getTBAATypeInfo(type); if (tbaa) CGM.DecorateInstructionWithTBAA(load, tbaa); } @@ -3780,7 +3777,7 @@ LValue CodeGenFunction::EmitLValueForFie // FIXME: this should get propagated down through anonymous structs // and unions. if (mayAlias && LV.getTBAAAccessType()) -LV.setTBAAAccessType(CGM.getTBAATypeInfo(getContext().CharTy)); +LV.setTBAAAccessType(CGM.getTBAAMayAliasTypeInfo()); return LV; } Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=314660&r1=314659&r2=314660&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Oct 2 04:10:04 2017 @@ -599,6 +599,12 @@ llvm::MDNode *CodeGenModule::getTBAAStru return TBAA->getTBAAStructTagInfo(BaseTy, AccessN, O); } +llvm::MDNode *CodeGenModule::getTBAAMayAliasTypeInfo() { + if (!TBAA) +return nullptr; + return TBAA->getMayAliasTypeInfo(); +} + /// Decorate the instruction with a TBAA tag. For both scalar TBAA /// and struct-path aware TBAA, the tag has the same format: /// base type, access type and offset. Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=314660&r1=314659&r2=314660&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Oct 2 04:10:04 2017 @@ -662,6 +662,10 @@ public: llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN, uint64_t O); + /// getTBAAMayAliasTypeInfo - Get TBAA information that represents + /// may-alias accesses. + llvm::MDNode *getTBAAMayAliasTypeInfo(); + bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor); bool isPaddedAtomicType(QualType type); Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=314660&r1=314659&r2=314660&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Mon Oct 2 04:10:04 2017 @@ -326,3 +326,7 @@ CodeGenTBAA::getTBAAScalarTagInfo(llvm:: return ScalarTagMetadataCache[AccessNode] = MDHelper.createTBAAStructTagNode(AccessNode, AccessNode, 0); } + +llvm::MDNode *CodeGenTBAA::getMayAliasTypeInfo() { + return getChar(); +} Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.h?r
r314657 - [CodeGen] Do not refer to complete TBAA info where we actually deal with just TBAA access types
Author: kosarev Date: Mon Oct 2 02:54:47 2017 New Revision: 314657 URL: http://llvm.org/viewvc/llvm-project?rev=314657&view=rev Log: [CodeGen] Do not refer to complete TBAA info where we actually deal with just TBAA access types This patch fixes misleading names of entities related to getting, setting and generation of TBAA access type descriptors. This is effectively an attempt to provide a review for D37826 by breaking it into smaller pieces. Differential Revision: https://reviews.llvm.org/D38404 Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGValue.h cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=314657&r1=314656&r2=314657&view=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Mon Oct 2 02:54:47 2017 @@ -98,7 +98,7 @@ namespace { LVal = LValue::MakeBitfield(Address(Addr, lvalue.getAlignment()), BFI, lvalue.getType(), lvalue.getBaseInfo()); -LVal.setTBAAInfo(lvalue.getTBAAInfo()); +LVal.setTBAAAccessType(lvalue.getTBAAAccessType()); AtomicTy = C.getIntTypeForBitwidth(AtomicSizeInBits, OrigBFI.IsSigned); if (AtomicTy.isNull()) { llvm::APInt Size( @@ -205,7 +205,7 @@ namespace { addr = CGF.Builder.CreateStructGEP(addr, 0, CharUnits()); return LValue::MakeAddr(addr, getValueType(), CGF.getContext(), - LVal.getBaseInfo(), LVal.getTBAAInfo()); + LVal.getBaseInfo(), LVal.getTBAAAccessType()); } /// \brief Emits atomic load. @@ -1425,8 +1425,8 @@ llvm::Value *AtomicInfo::EmitAtomicLoadO // Other decoration. if (IsVolatile) Load->setVolatile(true); - if (LVal.getTBAAInfo()) -CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAInfo()); + if (LVal.getTBAAAccessType()) +CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAAccessType()); return Load; } @@ -1692,8 +1692,8 @@ EmitAtomicUpdateValue(CodeGenFunction &C DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), AtomicLVal.getBaseInfo()); } -UpdateLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); -DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); +UpdateLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); +DesiredLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); UpRVal = CGF.EmitLoadOfLValue(UpdateLVal, SourceLocation()); } // Store new value in the corresponding memory area @@ -1789,7 +1789,7 @@ static void EmitAtomicUpdateValue(CodeGe DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), AtomicLVal.getBaseInfo()); } - DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); + DesiredLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); // Store new value in the corresponding memory area assert(UpdateRVal.isScalar()); CGF.EmitStoreThroughLValue(UpdateRVal, DesiredLVal); @@ -1942,8 +1942,8 @@ void CodeGenFunction::EmitAtomicStore(RV // Other decoration. if (IsVolatile) store->setVolatile(true); -if (dest.getTBAAInfo()) - CGM.DecorateInstructionWithTBAA(store, dest.getTBAAInfo()); +if (dest.getTBAAAccessType()) + CGM.DecorateInstructionWithTBAA(store, dest.getTBAAAccessType()); return; } Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=314657&r1=314656&r2=314657&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 2 02:54:47 2017 @@ -1165,7 +1165,7 @@ LValue CodeGenFunction::EmitLValue(const Scope.ForceCleanup({&V}); return LValue::MakeAddr(Address(V, LV.getAlignment()), LV.getType(), getContext(), LV.getBaseInfo(), - LV.getTBAAInfo()); + LV.getTBAAAccessType()); } // FIXME: Is it possible to create an ExprWithCleanups that produces a // bitfield lvalue or some other non-simple lvalue? @@ -1365,7 +1365,7 @@ llvm::Value *CodeGenFunction::EmitLoadOf SourceLocation Loc) { return EmitLoadOfScalar(lvalue.getAddress(), lvalue.isVolatile(), lvalue.getType(), Loc, lvalue.getBaseInfo(), - lvalue.getTBAAInfo(), +
r314780 - [CodeGen] Introduce generic TBAA access descriptors
Author: kosarev Date: Tue Oct 3 03:52:39 2017 New Revision: 314780 URL: http://llvm.org/viewvc/llvm-project?rev=314780&view=rev Log: [CodeGen] Introduce generic TBAA access descriptors With this patch we implement a concept of TBAA access descriptors that are capable of representing both scalar and struct-path accesses in a generic way. This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38456 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGValue.h cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=314780&r1=314779&r2=314780&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Oct 3 03:52:39 2017 @@ -1375,9 +1375,7 @@ llvm::Value *CodeGenFunction::EmitLoadOf SourceLocation Loc) { return EmitLoadOfScalar(lvalue.getAddress(), lvalue.isVolatile(), lvalue.getType(), Loc, lvalue.getBaseInfo(), - lvalue.getTBAAAccessType(), - lvalue.getTBAABaseType(), lvalue.getTBAAOffset(), - lvalue.isNontemporal()); + lvalue.getTBAAInfo(), lvalue.isNontemporal()); } static bool hasBooleanRepresentation(QualType Ty) { @@ -1487,9 +1485,7 @@ llvm::Value *CodeGenFunction::EmitLoadOf QualType Ty, SourceLocation Loc, LValueBaseInfo BaseInfo, - llvm::MDNode *TBAAAccessType, - QualType TBAABaseType, - uint64_t TBAAOffset, + TBAAAccessInfo TBAAInfo, bool isNontemporal) { if (!CGM.getCodeGenOpts().PreserveVec3Type) { // For better performance, handle vector loads differently. @@ -1518,7 +1514,7 @@ llvm::Value *CodeGenFunction::EmitLoadOf // Atomic operations have to be done on integral types. LValue AtomicLValue = - LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAAccessType); + LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo.AccessType); if (Ty->isAtomicType() || LValueIsSuitableForInlineAtomic(AtomicLValue)) { return EmitAtomicLoad(AtomicLValue, Loc).getScalarVal(); } @@ -1529,11 +1525,11 @@ llvm::Value *CodeGenFunction::EmitLoadOf Load->getContext(), llvm::ConstantAsMetadata::get(Builder.getInt32(1))); Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node); } - if (TBAAAccessType) { + if (TBAAInfo.AccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias ? CGM.getTBAAMayAliasTypeInfo() -: CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); +: CGM.getTBAAStructTagInfo(TBAAInfo); if (TBAA) CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias); } @@ -1576,11 +1572,8 @@ llvm::Value *CodeGenFunction::EmitFromMe void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, LValueBaseInfo BaseInfo, -llvm::MDNode *TBAAAccessType, -bool isInit, QualType TBAABaseType, -uint64_t TBAAOffset, -bool isNontemporal) { - +TBAAAccessInfo TBAAInfo, +bool isInit, bool isNontemporal) { if (!CGM.getCodeGenOpts().PreserveVec3Type) { // Handle vectors differently to get better performance. if (Ty->isVectorType()) { @@ -1606,7 +1599,7 @@ void CodeGenFunction::EmitStoreOfScalar( Value = EmitToMemory(Value, Ty); LValue AtomicLValue = - LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAAccessType); + LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo.AccessType); if (Ty->isAtomicType() || (!isInit && LValueIsSuitableForInlineAtomic(AtomicLValue))) { EmitAtomicStore(RValue::get(Value), AtomicLValue, isInit); @@ -1620,11 +1613,11 @@ void CodeGenFunction::EmitStoreOfScalar( llvm::ConstantAsMetadata::get(Builder.getInt32(1))); Store->setMetadata(CGM.getModule().getMDKindID("nontemporal"), N
r314784 - [CodeGen] Fix propagation of TBAA info for atomic accesses
Author: kosarev Date: Tue Oct 3 04:31:42 2017 New Revision: 314784 URL: http://llvm.org/viewvc/llvm-project?rev=314784&view=rev Log: [CodeGen] Fix propagation of TBAA info for atomic accesses This patch fixes clang to propagate complete TBAA information for atomic accesses and not just the final access types. Prepared against D38456 and requires it to be committed first. This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38460 Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=314784&r1=314783&r2=314784&view=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Tue Oct 3 04:31:42 2017 @@ -98,7 +98,7 @@ namespace { LVal = LValue::MakeBitfield(Address(Addr, lvalue.getAlignment()), BFI, lvalue.getType(), lvalue.getBaseInfo()); -LVal.setTBAAAccessType(lvalue.getTBAAAccessType()); +LVal.setTBAAInfo(lvalue.getTBAAInfo()); AtomicTy = C.getIntTypeForBitwidth(AtomicSizeInBits, OrigBFI.IsSigned); if (AtomicTy.isNull()) { llvm::APInt Size( @@ -1692,8 +1692,8 @@ EmitAtomicUpdateValue(CodeGenFunction &C DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), AtomicLVal.getBaseInfo()); } -UpdateLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); -DesiredLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); +UpdateLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); +DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); UpRVal = CGF.EmitLoadOfLValue(UpdateLVal, SourceLocation()); } // Store new value in the corresponding memory area @@ -1789,7 +1789,7 @@ static void EmitAtomicUpdateValue(CodeGe DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), AtomicLVal.getBaseInfo()); } - DesiredLVal.setTBAAAccessType(AtomicLVal.getTBAAAccessType()); + DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); // Store new value in the corresponding memory area assert(UpdateRVal.isScalar()); CGF.EmitStoreThroughLValue(UpdateRVal, DesiredLVal); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314977 - [CodeGen] Unify generation of scalar and struct-path TBAA tags
Author: kosarev Date: Thu Oct 5 03:47:51 2017 New Revision: 314977 URL: http://llvm.org/viewvc/llvm-project?rev=314977&view=rev Log: [CodeGen] Unify generation of scalar and struct-path TBAA tags This patch makes it possible to produce access tags in a uniform manner regardless whether the resulting tag will be a scalar or a struct-path one. getAccessTagInfo() now takes care of the actual translation of access descriptors to tags and can handle all kinds of accesses. Facilities that specific to scalar accesses are eliminated. Some more details: * DecorateInstructionWithTBAA() is not responsible for conversion of types to access tags anymore. Instead, it takes an access descriptor (TBAAAccessInfo) and generates corresponding access tag from it. * getTBAAInfoForVTablePtr() reworked to getTBAAVTablePtrAccessInfo() that now returns the virtual-pointer access descriptor and not the virtual-point type metadata. * Added function getTBAAMayAliasAccessInfo() that returns the descriptor for may-alias accesses. * getTBAAStructTagInfo() renamed to getTBAAAccessTagInfo() as now it is the only way to generate access tag by a given access descriptor. It is capable of producing both scalar and struct-path tags, depending on options and availability of the base access type. getTBAAScalarTagInfo() and its cache ScalarTagMetadataCache are eliminated. * Now that we do not need to care about whether the resulting access tag should be a scalar or struct-path one, getTBAAStructTypeInfo() is renamed to getBaseTypeInfo(). * Added function getTBAAAccessInfo() that constructs access descriptor by a given QualType access type. This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38503 Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGValue.h cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=314977&r1=314976&r2=314977&view=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Thu Oct 5 03:47:51 2017 @@ -205,7 +205,7 @@ namespace { addr = CGF.Builder.CreateStructGEP(addr, 0, CharUnits()); return LValue::MakeAddr(addr, getValueType(), CGF.getContext(), - LVal.getBaseInfo(), LVal.getTBAAAccessType()); + LVal.getBaseInfo(), LVal.getTBAAInfo()); } /// \brief Emits atomic load. @@ -1425,8 +1425,7 @@ llvm::Value *AtomicInfo::EmitAtomicLoadO // Other decoration. if (IsVolatile) Load->setVolatile(true); - if (LVal.getTBAAAccessType()) -CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAAccessType()); + CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAInfo()); return Load; } @@ -1942,8 +1941,7 @@ void CodeGenFunction::EmitAtomicStore(RV // Other decoration. if (IsVolatile) store->setVolatile(true); -if (dest.getTBAAAccessType()) - CGM.DecorateInstructionWithTBAA(store, dest.getTBAAAccessType()); +CGM.DecorateInstructionWithTBAA(store, dest.getTBAAInfo()); return; } Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=314977&r1=314976&r2=314977&view=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Oct 5 03:47:51 2017 @@ -2383,7 +2383,7 @@ void CodeGenFunction::InitializeVTablePo VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy); llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField); - CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAInfoForVTablePtr()); + CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAVTablePtrAccessInfo()); if (CGM.getCodeGenOpts().OptimizationLevel > 0 && CGM.getCodeGenOpts().StrictVTablePointers) CGM.DecorateInstructionWithInvariantGroup(Store, Vptr.VTableClass); @@ -2477,7 +2477,7 @@ llvm::Value *CodeGenFunction::GetVTableP const CXXRecordDecl *RD) { Address VTablePtrSrc = Builder.CreateElementBitCast(This, VTableTy); llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc, "vtable"); - CGM.DecorateInstructionWithTBAA(VTable, CGM.getTBAAInfoForVTablePtr()); + CGM.DecorateInstructionWithTBAA(VTable, CGM.getTBAAVTablePtrAccessInfo()); if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
r314978 - Revert r314977 "[CodeGen] Unify generation of scalar and struct-path TBAA tags"
Author: kosarev Date: Thu Oct 5 04:05:43 2017 New Revision: 314978 URL: http://llvm.org/viewvc/llvm-project?rev=314978&view=rev Log: Revert r314977 "[CodeGen] Unify generation of scalar and struct-path TBAA tags" D37826 has been mistakenly committed where it should be the patch from D38503. Differential Revision: https://reviews.llvm.org/D38503 Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGValue.h cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=314978&r1=314977&r2=314978&view=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Thu Oct 5 04:05:43 2017 @@ -205,7 +205,7 @@ namespace { addr = CGF.Builder.CreateStructGEP(addr, 0, CharUnits()); return LValue::MakeAddr(addr, getValueType(), CGF.getContext(), - LVal.getBaseInfo(), LVal.getTBAAInfo()); + LVal.getBaseInfo(), LVal.getTBAAAccessType()); } /// \brief Emits atomic load. @@ -1425,7 +1425,8 @@ llvm::Value *AtomicInfo::EmitAtomicLoadO // Other decoration. if (IsVolatile) Load->setVolatile(true); - CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAInfo()); + if (LVal.getTBAAAccessType()) +CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAAccessType()); return Load; } @@ -1941,7 +1942,8 @@ void CodeGenFunction::EmitAtomicStore(RV // Other decoration. if (IsVolatile) store->setVolatile(true); -CGM.DecorateInstructionWithTBAA(store, dest.getTBAAInfo()); +if (dest.getTBAAAccessType()) + CGM.DecorateInstructionWithTBAA(store, dest.getTBAAAccessType()); return; } Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=314978&r1=314977&r2=314978&view=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Oct 5 04:05:43 2017 @@ -2383,7 +2383,7 @@ void CodeGenFunction::InitializeVTablePo VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy); llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField); - CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAVTablePtrAccessInfo()); + CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAInfoForVTablePtr()); if (CGM.getCodeGenOpts().OptimizationLevel > 0 && CGM.getCodeGenOpts().StrictVTablePointers) CGM.DecorateInstructionWithInvariantGroup(Store, Vptr.VTableClass); @@ -2477,7 +2477,7 @@ llvm::Value *CodeGenFunction::GetVTableP const CXXRecordDecl *RD) { Address VTablePtrSrc = Builder.CreateElementBitCast(This, VTableTy); llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc, "vtable"); - CGM.DecorateInstructionWithTBAA(VTable, CGM.getTBAAVTablePtrAccessInfo()); + CGM.DecorateInstructionWithTBAA(VTable, CGM.getTBAAInfoForVTablePtr()); if (CGM.getCodeGenOpts().OptimizationLevel > 0 && CGM.getCodeGenOpts().StrictVTablePointers) Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=314978&r1=314977&r2=314978&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Oct 5 04:05:43 2017 @@ -1174,7 +1174,8 @@ LValue CodeGenFunction::EmitLValue(const llvm::Value *V = LV.getPointer(); Scope.ForceCleanup({&V}); return LValue::MakeAddr(Address(V, LV.getAlignment()), LV.getType(), - getContext(), LV.getBaseInfo(), LV.getTBAAInfo()); + getContext(), LV.getBaseInfo(), + LV.getTBAAAccessType()); } // FIXME: Is it possible to create an ExprWithCleanups that produces a // bitfield lvalue or some other non-simple lvalue? @@ -1513,7 +1514,7 @@ llvm::Value *CodeGenFunction::EmitLoadOf // Atomic operations have to be done on integral types. LValue AtomicLValue = - LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo); + LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo.AccessType); if (Ty->isAtomicType() || LValueIsSuitableForInlineAtomic(AtomicLValue)) { return EmitAtomicLoad(AtomicLValue, Loc).getScalarVal(); } @@ -1524,10 +1525,14 @@ llvm::Value *CodeGenFu
r314979 - [CodeGen] Unify generation of scalar and struct-path TBAA tags
Author: kosarev Date: Thu Oct 5 04:08:17 2017 New Revision: 314979 URL: http://llvm.org/viewvc/llvm-project?rev=314979&view=rev Log: [CodeGen] Unify generation of scalar and struct-path TBAA tags This patch makes it possible to produce access tags in a uniform manner regardless whether the resulting tag will be a scalar or a struct-path one. getAccessTagInfo() now takes care of the actual translation of access descriptors to tags and can handle all kinds of accesses. Facilities that specific to scalar accesses are eliminated. Some more details: * DecorateInstructionWithTBAA() is not responsible for conversion of types to access tags anymore. Instead, it takes an access descriptor (TBAAAccessInfo) and generates corresponding access tag from it. * getTBAAInfoForVTablePtr() reworked to getTBAAVTablePtrAccessInfo() that now returns the virtual-pointer access descriptor and not the virtual-point type metadata. * Added function getTBAAMayAliasAccessInfo() that returns the descriptor for may-alias accesses. * getTBAAStructTagInfo() renamed to getTBAAAccessTagInfo() as now it is the only way to generate access tag by a given access descriptor. It is capable of producing both scalar and struct-path tags, depending on options and availability of the base access type. getTBAAScalarTagInfo() and its cache ScalarTagMetadataCache are eliminated. * Now that we do not need to care about whether the resulting access tag should be a scalar or struct-path one, getTBAAStructTypeInfo() is renamed to getBaseTypeInfo(). * Added function getTBAAAccessInfo() that constructs access descriptor by a given QualType access type. This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38503 Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=314979&r1=314978&r2=314979&view=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Thu Oct 5 04:08:17 2017 @@ -1425,8 +1425,8 @@ llvm::Value *AtomicInfo::EmitAtomicLoadO // Other decoration. if (IsVolatile) Load->setVolatile(true); - if (LVal.getTBAAAccessType()) -CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAAccessType()); + TBAAAccessInfo TBAAInfo(LVal.getTBAAAccessType()); + CGF.CGM.DecorateInstructionWithTBAA(Load, TBAAInfo); return Load; } @@ -1942,8 +1942,8 @@ void CodeGenFunction::EmitAtomicStore(RV // Other decoration. if (IsVolatile) store->setVolatile(true); -if (dest.getTBAAAccessType()) - CGM.DecorateInstructionWithTBAA(store, dest.getTBAAAccessType()); +TBAAAccessInfo TBAAInfo(dest.getTBAAAccessType()); +CGM.DecorateInstructionWithTBAA(store, TBAAInfo); return; } Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=314979&r1=314978&r2=314979&view=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Oct 5 04:08:17 2017 @@ -2383,7 +2383,7 @@ void CodeGenFunction::InitializeVTablePo VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy); llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField); - CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAInfoForVTablePtr()); + CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAVTablePtrAccessInfo()); if (CGM.getCodeGenOpts().OptimizationLevel > 0 && CGM.getCodeGenOpts().StrictVTablePointers) CGM.DecorateInstructionWithInvariantGroup(Store, Vptr.VTableClass); @@ -2477,7 +2477,7 @@ llvm::Value *CodeGenFunction::GetVTableP const CXXRecordDecl *RD) { Address VTablePtrSrc = Builder.CreateElementBitCast(This, VTableTy); llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc, "vtable"); - CGM.DecorateInstructionWithTBAA(VTable, CGM.getTBAAInfoForVTablePtr()); + CGM.DecorateInstructionWithTBAA(VTable, CGM.getTBAAVTablePtrAccessInfo()); if (CGM.getCodeGenOpts().OptimizationLevel > 0 && CGM.getCodeGenOpts().StrictVTablePointers) Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=314979&r1=314978&r2=314979&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Oct 5 04:08:17 2017 @@ -
r315048 - Refine generation of TBAA information in clang
Author: kosarev Date: Fri Oct 6 01:17:48 2017 New Revision: 315048 URL: http://llvm.org/viewvc/llvm-project?rev=315048&view=rev Log: Refine generation of TBAA information in clang This patch is an attempt to clarify and simplify generation and propagation of TBAA information. The idea is to pack all values that describe a memory access, namely, base type, access type and offset, into a single structure. This is supposed to make further changes, such as adding support for unions and array members, easier to prepare and review. DecorateInstructionWithTBAA() is no more responsible for converting types to tags. These implicit conversions not only complicate reading the code, but also suggest assigning scalar access tags while we generally prefer full-size struct-path tags. TBAAPathTag is replaced with TBAAAccessInfo; the latter is now the type of the keys of the cache map that translates access descriptors to metadata nodes. Fixed a bug with writing to a wrong map in getTBAABaseTypeMetadata() (former getTBAAStructTypeInfo()). We now check for valid base access types every time we dereference a field. The original code only checks the top-level base type. See isValidBaseType() / isTBAAPathStruct() calls. Some entities have been renamed to sound more adequate and less confusing/misleading in presence of path-aware TBAA information. Now we do not lookup twice for the same cache entry in getAccessTagInfo(). Refined relevant comments and descriptions. Differential Revision: https://reviews.llvm.org/D37826 Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGValue.h cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=315048&r1=315047&r2=315048&view=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Fri Oct 6 01:17:48 2017 @@ -205,7 +205,7 @@ namespace { addr = CGF.Builder.CreateStructGEP(addr, 0, CharUnits()); return LValue::MakeAddr(addr, getValueType(), CGF.getContext(), - LVal.getBaseInfo(), LVal.getTBAAAccessType()); + LVal.getBaseInfo(), LVal.getTBAAInfo()); } /// \brief Emits atomic load. @@ -1425,8 +1425,7 @@ llvm::Value *AtomicInfo::EmitAtomicLoadO // Other decoration. if (IsVolatile) Load->setVolatile(true); - TBAAAccessInfo TBAAInfo(LVal.getTBAAAccessType()); - CGF.CGM.DecorateInstructionWithTBAA(Load, TBAAInfo); + CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAInfo()); return Load; } @@ -1942,8 +1941,7 @@ void CodeGenFunction::EmitAtomicStore(RV // Other decoration. if (IsVolatile) store->setVolatile(true); -TBAAAccessInfo TBAAInfo(dest.getTBAAAccessType()); -CGM.DecorateInstructionWithTBAA(store, TBAAInfo); +CGM.DecorateInstructionWithTBAA(store, dest.getTBAAInfo()); return; } Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315048&r1=315047&r2=315048&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 6 01:17:48 2017 @@ -1174,8 +1174,7 @@ LValue CodeGenFunction::EmitLValue(const llvm::Value *V = LV.getPointer(); Scope.ForceCleanup({&V}); return LValue::MakeAddr(Address(V, LV.getAlignment()), LV.getType(), - getContext(), LV.getBaseInfo(), - LV.getTBAAAccessType()); + getContext(), LV.getBaseInfo(), LV.getTBAAInfo()); } // FIXME: Is it possible to create an ExprWithCleanups that produces a // bitfield lvalue or some other non-simple lvalue? @@ -1514,7 +1513,7 @@ llvm::Value *CodeGenFunction::EmitLoadOf // Atomic operations have to be done on integral types. LValue AtomicLValue = - LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo.AccessType); + LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo); if (Ty->isAtomicType() || LValueIsSuitableForInlineAtomic(AtomicLValue)) { return EmitAtomicLoad(AtomicLValue, Loc).getScalarVal(); } @@ -1525,11 +1524,10 @@ llvm::Value *CodeGenFunction::EmitLoadOf Load->getContext(), llvm::ConstantAsMetadata::get(Builder.getInt32(1))); Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node); } - if (TBAAInfo.AccessType) { -if (BaseInfo.getMayAlias()) - T
r315289 - [CodeGen] Do not construct complete LValue base info in trivial cases
Author: kosarev Date: Tue Oct 10 02:39:32 2017 New Revision: 315289 URL: http://llvm.org/viewvc/llvm-project?rev=315289&view=rev Log: [CodeGen] Do not construct complete LValue base info in trivial cases Besides obvious code simplification, avoiding explicit creation of LValueBaseInfo objects makes it easier to make TBAA information to be part of such objects. This is part of D38126 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38695 Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=315289&r1=315288&r2=315289&view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Oct 10 02:39:32 2017 @@ -986,9 +986,8 @@ llvm::Value *CodeGenFunction::EmitBlockL // FIXME: Pass a specific location for the expr init so that the store is // attributed to a reasonable location - otherwise it may be attributed to // locations of subexpressions in the initialization. - LValueBaseInfo BaseInfo(AlignmentSource::Decl, false); EmitExprAsInit(&l2r, &BlockFieldPseudoVar, - MakeAddrLValue(blockField, type, BaseInfo), + MakeAddrLValue(blockField, type, AlignmentSource::Decl), /*captured by init*/ false); } Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315289&r1=315288&r2=315289&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Oct 10 02:39:32 2017 @@ -412,14 +412,12 @@ EmitMaterializeTemporaryExpr(const Mater // dynamic initialization or a cleanup and we can just return the address // of the temporary. if (Var->hasInitializer()) -return MakeAddrLValue(Object, M->getType(), - LValueBaseInfo(AlignmentSource::Decl, false)); +return MakeAddrLValue(Object, M->getType(), AlignmentSource::Decl); Var->setInitializer(CGM.EmitNullConstant(E->getType())); } LValue RefTempDst = MakeAddrLValue(Object, M->getType(), - LValueBaseInfo(AlignmentSource::Decl, - false)); + AlignmentSource::Decl); switch (getEvaluationKind(E->getType())) { default: llvm_unreachable("expected scalar or aggregate expression"); @@ -506,8 +504,7 @@ EmitMaterializeTemporaryExpr(const Mater break; case SubobjectAdjustment::FieldAdjustment: { - LValue LV = MakeAddrLValue(Object, E->getType(), - LValueBaseInfo(AlignmentSource::Decl, false)); + LValue LV = MakeAddrLValue(Object, E->getType(), AlignmentSource::Decl); LV = EmitLValueForField(LV, Adjustment.Field); assert(LV.isSimple() && "materialized temporary field is not a simple lvalue"); @@ -524,8 +521,7 @@ EmitMaterializeTemporaryExpr(const Mater } } - return MakeAddrLValue(Object, M->getType(), -LValueBaseInfo(AlignmentSource::Decl, false)); + return MakeAddrLValue(Object, M->getType(), AlignmentSource::Decl); } RValue @@ -2148,8 +2144,7 @@ static LValue EmitThreadPrivateVarDeclLV llvm::Type *RealVarTy, SourceLocation Loc) { Addr = CGF.CGM.getOpenMPRuntime().getAddrOfThreadPrivate(CGF, VD, Addr, Loc); Addr = CGF.Builder.CreateElementBitCast(Addr, RealVarTy); - LValueBaseInfo BaseInfo(AlignmentSource::Decl, false); - return CGF.MakeAddrLValue(Addr, T, BaseInfo); + return CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl); } Address CodeGenFunction::EmitLoadOfReference(Address Addr, @@ -2206,8 +2201,7 @@ static LValue EmitGlobalVarDeclLValue(Co if (auto RefTy = VD->getType()->getAs()) { LV = CGF.EmitLoadOfReferenceLValue(Addr, RefTy); } else { -LValueBaseInfo BaseInfo(AlignmentSource::Decl, false); -LV = CGF.MakeAddrLValue(Addr, T, BaseInfo); +LV = CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl); } setObjCGCLValueClass(CGF.getContext(), E, LV); return LV; @@ -2241,8 +2235,8 @@ static LValue EmitFunctionDeclLValue(Cod const Expr *E, const FunctionDecl *FD) { llvm::Value *V = EmitFunctionDeclPointer(CGF.CGM, FD); CharUnits Alignment = CGF.getContext().getDeclAlign(FD); - LValueBaseInfo BaseInfo(AlignmentSource::Decl, false); - return CGF.MakeAddrLValue(V, E->getType(), Alignment,
r315575 - [CodeGen] Generate TBAA info along with LValue base info
Author: kosarev Date: Thu Oct 12 04:29:46 2017 New Revision: 315575 URL: http://llvm.org/viewvc/llvm-project?rev=315575&view=rev Log: [CodeGen] Generate TBAA info along with LValue base info This patch enables explicit generation of TBAA information in all cases where LValue base info is propagated or constructed in non-trivial ways. Eventually, we will consider each of these cases to make sure the TBAA information is correct and not too conservative. For now, we just fall back to generating TBAA info from the access type. This patch should not bring in any functional changes. This is part of D38126 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38733 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315575&r1=315574&r2=315575&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Oct 12 04:29:46 2017 @@ -2159,7 +2159,8 @@ LValue CodeGenFunction::EmitLoadOfRefere const ReferenceType *RefTy) { LValueBaseInfo BaseInfo; Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo); - return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo); + return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo, +CGM.getTBAAAccessInfo(RefTy->getPointeeType())); } Address CodeGenFunction::EmitLoadOfPointer(Address Ptr, @@ -2175,7 +2176,8 @@ LValue CodeGenFunction::EmitLoadOfPointe const PointerType *PtrTy) { LValueBaseInfo BaseInfo; Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &BaseInfo); - return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo); + return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo, +CGM.getTBAAAccessInfo(PtrTy->getPointeeType())); } static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF, @@ -2328,7 +2330,8 @@ LValue CodeGenFunction::EmitDeclRefLValu bool MayAlias = CapLVal.getBaseInfo().getMayAlias(); return MakeAddrLValue( Address(CapLVal.getPointer(), getContext().getDeclAlign(VD)), -CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl, MayAlias)); +CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl, MayAlias), +CGM.getTBAAAccessInfo(CapLVal.getType())); } assert(isa(CurCodeDecl)); @@ -2440,7 +2443,7 @@ LValue CodeGenFunction::EmitUnaryOpLValu LValueBaseInfo BaseInfo; Address Addr = EmitPointerWithAlignment(E->getSubExpr(), &BaseInfo); -LValue LV = MakeAddrLValue(Addr, T, BaseInfo); +LValue LV = MakeAddrLValue(Addr, T, BaseInfo, CGM.getTBAAAccessInfo(T)); LV.getQuals().setAddressSpace(ExprTy.getAddressSpace()); // We should not generate __weak write barrier on indirect reference @@ -2472,7 +2475,8 @@ LValue CodeGenFunction::EmitUnaryOpLValu (E->getOpcode() == UO_Real ? emitAddrOfRealComponent(LV.getAddress(), LV.getType()) : emitAddrOfImagComponent(LV.getAddress(), LV.getType())); -LValue ElemLV = MakeAddrLValue(Component, T, LV.getBaseInfo()); +LValue ElemLV = MakeAddrLValue(Component, T, LV.getBaseInfo(), + CGM.getTBAAAccessInfo(T)); ElemLV.getQuals().addQualifiers(LV.getQuals()); return ElemLV; } @@ -3202,7 +3206,8 @@ LValue CodeGenFunction::EmitArraySubscri QualType EltType = LV.getType()->castAs()->getElementType(); Addr = emitArraySubscriptGEP(*this, Addr, Idx, EltType, /*inbounds*/ true, SignedIndices, E->getExprLoc()); -return MakeAddrLValue(Addr, EltType, LV.getBaseInfo()); +return MakeAddrLValue(Addr, EltType, LV.getBaseInfo(), + CGM.getTBAAAccessInfo(EltType)); } LValueBaseInfo BaseInfo; @@ -3293,7 +3298,8 @@ LValue CodeGenFunction::EmitArraySubscri SignedIndices, E->getExprLoc()); } - LValue LV = MakeAddrLValue(Addr, E->getType(), BaseInfo); + LValue LV = MakeAddrLValue(Addr, E->getType(), BaseInfo, + CGM.getTBAAAccessInfo(E->getType())); // TODO: Preserve/extend path TBAA metadata? @@ -3493,7 +3499,8 @@ LValue CodeGenFunction::EmitOMPArraySect /*SignedIndices=*/false, E->getExprLoc()); } - return MakeAddrLValue(EltPtr, ResultExprTy, BaseInfo); + return MakeAddrLValue(EltPtr, ResultExprTy, BaseInfo, +CGM.getTBAAAccessInfo(ResultExprTy)); } LValue CodeGenFunction:: @@ -3508,7 +3515,8 @@ EmitExtVectorElementExpr(const ExtVector
r315702 - [CodeGen] EmitCXXMemberDataPointerAddress() to generate TBAA info along with LValue base info
Author: kosarev Date: Fri Oct 13 09:38:32 2017 New Revision: 315702 URL: http://llvm.org/viewvc/llvm-project?rev=315702&view=rev Log: [CodeGen] EmitCXXMemberDataPointerAddress() to generate TBAA info along with LValue base info This patch should not bring in any functional changes. Differential Revision: https://reviews.llvm.org/D38788 Modified: cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=315702&r1=315701&r2=315702&view=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Oct 13 09:38:32 2017 @@ -129,13 +129,16 @@ Address CodeGenFunction::EmitCXXMemberDataPointerAddress(const Expr *E, Address base, llvm::Value *memberPtr, const MemberPointerType *memberPtrType, - LValueBaseInfo *BaseInfo) { + LValueBaseInfo *BaseInfo, + TBAAAccessInfo *TBAAInfo) { // Ask the ABI to compute the actual address. llvm::Value *ptr = CGM.getCXXABI().EmitMemberDataPointerAddress(*this, E, base, memberPtr, memberPtrType); QualType memberType = memberPtrType->getPointeeType(); + if (TBAAInfo) +*TBAAInfo = CGM.getTBAAAccessInfo(memberType); CharUnits memberAlign = getNaturalTypeAlignment(memberType, BaseInfo); memberAlign = CGM.getDynamicOffsetAlignment(base.getAlignment(), Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315702&r1=315701&r2=315702&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 13 09:38:32 2017 @@ -4566,11 +4566,12 @@ EmitPointerToDataMemberBinaryExpr(const = E->getRHS()->getType()->getAs(); LValueBaseInfo BaseInfo; + TBAAAccessInfo TBAAInfo; Address MemberAddr = -EmitCXXMemberDataPointerAddress(E, BaseAddr, OffsetV, MPT, &BaseInfo); +EmitCXXMemberDataPointerAddress(E, BaseAddr, OffsetV, MPT, &BaseInfo, +&TBAAInfo); - return MakeAddrLValue(MemberAddr, MPT->getPointeeType(), BaseInfo, -CGM.getTBAAAccessInfo(MPT->getPointeeType())); + return MakeAddrLValue(MemberAddr, MPT->getPointeeType(), BaseInfo, TBAAInfo); } /// Given the address of a temporary variable, produce an r-value of Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=315702&r1=315701&r2=315702&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Oct 13 09:38:32 2017 @@ -3327,7 +3327,8 @@ public: Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base, llvm::Value *memberPtr, const MemberPointerType *memberPtrType, - LValueBaseInfo *BaseInfo = nullptr); + LValueBaseInfo *BaseInfo = nullptr, + TBAAAccessInfo *TBAAInfo = nullptr); RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315704 - [CodeGen] EmitLoadOfPointer() to generate TBAA info along with LValue base info
Author: kosarev Date: Fri Oct 13 09:47:22 2017 New Revision: 315704 URL: http://llvm.org/viewvc/llvm-project?rev=315704&view=rev Log: [CodeGen] EmitLoadOfPointer() to generate TBAA info along with LValue base info This patch should not bring in any functional changes. Differential Revision: https://reviews.llvm.org/D38791 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315704&r1=315703&r2=315704&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 13 09:47:22 2017 @@ -2165,7 +2165,11 @@ LValue CodeGenFunction::EmitLoadOfRefere Address CodeGenFunction::EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy, - LValueBaseInfo *BaseInfo) { + LValueBaseInfo *BaseInfo, + TBAAAccessInfo *TBAAInfo) { + if (TBAAInfo) +*TBAAInfo = CGM.getTBAAAccessInfo(PtrTy->getPointeeType()); + llvm::Value *Addr = Builder.CreateLoad(Ptr); return Address(Addr, getNaturalTypeAlignment(PtrTy->getPointeeType(), BaseInfo, @@ -2175,9 +2179,9 @@ Address CodeGenFunction::EmitLoadOfPoint LValue CodeGenFunction::EmitLoadOfPointerLValue(Address PtrAddr, const PointerType *PtrTy) { LValueBaseInfo BaseInfo; - Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &BaseInfo); - return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo, -CGM.getTBAAAccessInfo(PtrTy->getPointeeType())); + TBAAAccessInfo TBAAInfo; + Address Addr = EmitLoadOfPointer(PtrAddr, PtrTy, &BaseInfo, &TBAAInfo); + return MakeAddrLValue(Addr, PtrTy->getPointeeType(), BaseInfo, TBAAInfo); } static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF, Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=315704&r1=315703&r2=315704&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Oct 13 09:47:22 2017 @@ -1948,7 +1948,8 @@ public: LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy); Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy, -LValueBaseInfo *BaseInfo = nullptr); +LValueBaseInfo *BaseInfo = nullptr, +TBAAAccessInfo *TBAAInfo = nullptr); LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy); /// CreateTempAlloca - This creates an alloca and inserts it into the entry ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315705 - [CodeGen] EmitLoadOfReference() to generate TBAA info along with LValue base info
Author: kosarev Date: Fri Oct 13 09:50:50 2017 New Revision: 315705 URL: http://llvm.org/viewvc/llvm-project?rev=315705&view=rev Log: [CodeGen] EmitLoadOfReference() to generate TBAA info along with LValue base info This patch should not bring in any functional changes. Differential Revision: https://reviews.llvm.org/D38793 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315705&r1=315704&r2=315705&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 13 09:50:50 2017 @@ -2149,7 +2149,11 @@ static LValue EmitThreadPrivateVarDeclLV Address CodeGenFunction::EmitLoadOfReference(Address Addr, const ReferenceType *RefTy, - LValueBaseInfo *BaseInfo) { + LValueBaseInfo *BaseInfo, + TBAAAccessInfo *TBAAInfo) { + if (TBAAInfo) +*TBAAInfo = CGM.getTBAAAccessInfo(RefTy->getPointeeType()); + llvm::Value *Ptr = Builder.CreateLoad(Addr); return Address(Ptr, getNaturalTypeAlignment(RefTy->getPointeeType(), BaseInfo, /*forPointee*/ true)); @@ -2158,9 +2162,9 @@ Address CodeGenFunction::EmitLoadOfRefer LValue CodeGenFunction::EmitLoadOfReferenceLValue(Address RefAddr, const ReferenceType *RefTy) { LValueBaseInfo BaseInfo; - Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo); - return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo, -CGM.getTBAAAccessInfo(RefTy->getPointeeType())); + TBAAAccessInfo TBAAInfo; + Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo, &TBAAInfo); + return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo, TBAAInfo); } Address CodeGenFunction::EmitLoadOfPointer(Address Ptr, Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=315705&r1=315704&r2=315705&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Oct 13 09:50:50 2017 @@ -1944,7 +1944,8 @@ public: LValueBaseInfo *BaseInfo = nullptr); Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy, - LValueBaseInfo *BaseInfo = nullptr); + LValueBaseInfo *BaseInfo = nullptr, + TBAAAccessInfo *TBAAInfo = nullptr); LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy); Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315708 - [CodeGen] getNaturalTypeAlignment() to generate TBAA info along with LValue base info
Author: kosarev Date: Fri Oct 13 09:58:30 2017 New Revision: 315708 URL: http://llvm.org/viewvc/llvm-project?rev=315708&view=rev Log: [CodeGen] getNaturalTypeAlignment() to generate TBAA info along with LValue base info This patch should not bring in any functional changes. Differential Revision: https://reviews.llvm.org/D38794 Modified: cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=315708&r1=315707&r2=315708&view=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Oct 13 09:58:30 2017 @@ -137,9 +137,8 @@ CodeGenFunction::EmitCXXMemberDataPointe memberPtr, memberPtrType); QualType memberType = memberPtrType->getPointeeType(); - if (TBAAInfo) -*TBAAInfo = CGM.getTBAAAccessInfo(memberType); - CharUnits memberAlign = getNaturalTypeAlignment(memberType, BaseInfo); + CharUnits memberAlign = getNaturalTypeAlignment(memberType, BaseInfo, + TBAAInfo); memberAlign = CGM.getDynamicOffsetAlignment(base.getAlignment(), memberPtrType->getClass()->getAsCXXRecordDecl(), Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315708&r1=315707&r2=315708&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 13 09:58:30 2017 @@ -2151,12 +2151,10 @@ Address CodeGenFunction::EmitLoadOfRefer const ReferenceType *RefTy, LValueBaseInfo *BaseInfo, TBAAAccessInfo *TBAAInfo) { - if (TBAAInfo) -*TBAAInfo = CGM.getTBAAAccessInfo(RefTy->getPointeeType()); - llvm::Value *Ptr = Builder.CreateLoad(Addr); return Address(Ptr, getNaturalTypeAlignment(RefTy->getPointeeType(), - BaseInfo, /*forPointee*/ true)); + BaseInfo, TBAAInfo, + /* forPointeeType= */ true)); } LValue CodeGenFunction::EmitLoadOfReferenceLValue(Address RefAddr, @@ -2171,12 +2169,9 @@ Address CodeGenFunction::EmitLoadOfPoint const PointerType *PtrTy, LValueBaseInfo *BaseInfo, TBAAAccessInfo *TBAAInfo) { - if (TBAAInfo) -*TBAAInfo = CGM.getTBAAAccessInfo(PtrTy->getPointeeType()); - llvm::Value *Addr = Builder.CreateLoad(Ptr); return Address(Addr, getNaturalTypeAlignment(PtrTy->getPointeeType(), - BaseInfo, + BaseInfo, TBAAInfo, /*forPointeeType=*/true)); } @@ -2315,8 +2310,10 @@ LValue CodeGenFunction::EmitDeclRefLValu // FIXME: Eventually we will want to emit vector element references. // Should we be using the alignment of the constant pointer we emitted? - CharUnits Alignment = getNaturalTypeAlignment(E->getType(), nullptr, -/*pointee*/ true); + CharUnits Alignment = getNaturalTypeAlignment(E->getType(), +/* BaseInfo= */ nullptr, +/* TBAAInfo= */ nullptr, +/* forPointeeType= */ true); return MakeAddrLValue(Address(Val, Alignment), T, AlignmentSource::Decl); } @@ -3729,7 +3726,8 @@ LValue CodeGenFunction::EmitLValueForFie type = refType->getPointeeType(); CharUnits alignment = -getNaturalTypeAlignment(type, &FieldBaseInfo, /*pointee*/ true); +getNaturalTypeAlignment(type, &FieldBaseInfo, /* TBAAInfo= */ nullptr, +/* forPointeeType= */ true); FieldBaseInfo.setMayAlias(false); addr = Address(load, alignment); Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=315708&r1=315707&r2=315708&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Oct 13 09:58:30 2017 @@ -120,12 +120,17 @@ CodeGenFunction::~CodeGenFunction() { CharUnits CodeGenFunction::getNaturalPoint
r315715 - [CodeGen] emitOMPArraySectionBase() to generate TBAA info along with LValue base info
Author: kosarev Date: Fri Oct 13 10:34:18 2017 New Revision: 315715 URL: http://llvm.org/viewvc/llvm-project?rev=315715&view=rev Log: [CodeGen] emitOMPArraySectionBase() to generate TBAA info along with LValue base info Differential Revision: https://reviews.llvm.org/D38795 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315715&r1=315714&r2=315715&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 13 10:34:18 2017 @@ -3318,8 +3318,11 @@ LValue CodeGenFunction::EmitArraySubscri static Address emitOMPArraySectionBase(CodeGenFunction &CGF, const Expr *Base, LValueBaseInfo &BaseInfo, + TBAAAccessInfo &TBAAInfo, QualType BaseTy, QualType ElTy, bool IsLowerBound) { + TBAAInfo = CGF.CGM.getTBAAAccessInfo(ElTy); + LValue BaseLVal; if (auto *ASE = dyn_cast(Base->IgnoreParenImpCasts())) { BaseLVal = CGF.EmitOMPArraySectionExpr(ASE, IsLowerBound); @@ -3449,13 +3452,14 @@ LValue CodeGenFunction::EmitOMPArraySect Address EltPtr = Address::invalid(); LValueBaseInfo BaseInfo; + TBAAAccessInfo TBAAInfo; if (auto *VLA = getContext().getAsVariableArrayType(ResultExprTy)) { // The base must be a pointer, which is not an aggregate. Emit // it. It needs to be emitted first in case it's what captures // the VLA bounds. Address Base = -emitOMPArraySectionBase(*this, E->getBase(), BaseInfo, BaseTy, -VLA->getElementType(), IsLowerBound); +emitOMPArraySectionBase(*this, E->getBase(), BaseInfo, TBAAInfo, +BaseTy, VLA->getElementType(), IsLowerBound); // The element count here is the total number of non-VLA elements. llvm::Value *NumElements = getVLASize(VLA).first; @@ -3491,16 +3495,17 @@ LValue CodeGenFunction::EmitOMPArraySect ResultExprTy, !getLangOpts().isSignedOverflowDefined(), /*SignedIndices=*/false, E->getExprLoc()); BaseInfo = ArrayLV.getBaseInfo(); +TBAAInfo = CGM.getTBAAAccessInfo(ResultExprTy); } else { Address Base = emitOMPArraySectionBase(*this, E->getBase(), BaseInfo, - BaseTy, ResultExprTy, IsLowerBound); + TBAAInfo, BaseTy, ResultExprTy, + IsLowerBound); EltPtr = emitArraySubscriptGEP(*this, Base, Idx, ResultExprTy, !getLangOpts().isSignedOverflowDefined(), /*SignedIndices=*/false, E->getExprLoc()); } - return MakeAddrLValue(EltPtr, ResultExprTy, BaseInfo, -CGM.getTBAAAccessInfo(ResultExprTy)); + return MakeAddrLValue(EltPtr, ResultExprTy, BaseInfo, TBAAInfo); } LValue CodeGenFunction:: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315731 - [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info
Author: kosarev Date: Fri Oct 13 11:40:18 2017 New Revision: 315731 URL: http://llvm.org/viewvc/llvm-project?rev=315731&view=rev Log: [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info Differential Revision: https://reviews.llvm.org/D38796 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315731&r1=315730&r2=315731&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 13 11:40:18 2017 @@ -916,7 +916,8 @@ void CodeGenModule::EmitExplicitCastExpr /// EmitPointerWithAlignment - Given an expression of pointer type, try to /// derive a more accurate bound on the alignment of the pointer. Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E, - LValueBaseInfo *BaseInfo) { + LValueBaseInfo *BaseInfo, + TBAAAccessInfo *TBAAInfo) { // We allow this with ObjC object pointers because of fragile ABIs. assert(E->getType()->isPointerType() || E->getType()->isObjCObjectPointerType()); @@ -936,19 +937,28 @@ Address CodeGenFunction::EmitPointerWith if (PtrTy->getPointeeType()->isVoidType()) break; -LValueBaseInfo InnerInfo; -Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), &InnerInfo); -if (BaseInfo) *BaseInfo = InnerInfo; +LValueBaseInfo InnerBaseInfo; +TBAAAccessInfo InnerTBAAInfo; +Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), +&InnerBaseInfo, +&InnerTBAAInfo); +if (BaseInfo) *BaseInfo = InnerBaseInfo; +if (TBAAInfo) *TBAAInfo = InnerTBAAInfo; // If this is an explicit bitcast, and the source l-value is // opaque, honor the alignment of the casted-to type. if (isa(CE) && -InnerInfo.getAlignmentSource() != AlignmentSource::Decl) { - LValueBaseInfo ExpInfo; +InnerBaseInfo.getAlignmentSource() != AlignmentSource::Decl) { + LValueBaseInfo TargetTypeBaseInfo; + TBAAAccessInfo TargetTypeTBAAInfo; CharUnits Align = getNaturalPointeeTypeAlignment(E->getType(), - &ExpInfo); + &TargetTypeBaseInfo, + &TargetTypeTBAAInfo); if (BaseInfo) -BaseInfo->mergeForCast(ExpInfo); +BaseInfo->mergeForCast(TargetTypeBaseInfo); + if (TBAAInfo) +*TBAAInfo = CGM.mergeTBAAInfoForCast(*TBAAInfo, + TargetTypeTBAAInfo); Addr = Address(Addr.getPointer(), Align); } @@ -969,12 +979,13 @@ Address CodeGenFunction::EmitPointerWith // Array-to-pointer decay. case CK_ArrayToPointerDecay: - return EmitArrayToPointerDecay(CE->getSubExpr(), BaseInfo); + return EmitArrayToPointerDecay(CE->getSubExpr(), BaseInfo, TBAAInfo); // Derived-to-base conversions. case CK_UncheckedDerivedToBase: case CK_DerivedToBase: { - Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo); + Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo, + TBAAInfo); auto Derived = CE->getSubExpr()->getType()->getPointeeCXXRecordDecl(); return GetAddressOfBaseClass(Addr, Derived, CE->path_begin(), CE->path_end(), @@ -994,6 +1005,7 @@ Address CodeGenFunction::EmitPointerWith if (UO->getOpcode() == UO_AddrOf) { LValue LV = EmitLValue(UO->getSubExpr()); if (BaseInfo) *BaseInfo = LV.getBaseInfo(); + if (TBAAInfo) *TBAAInfo = LV.getTBAAInfo(); return LV.getAddress(); } } @@ -1001,7 +1013,8 @@ Address CodeGenFunction::EmitPointerWith // TODO: conditional operators, comma. // Otherwise, use the alignment of the type. - CharUnits Align = getNaturalPointeeTypeAlignment(E->getType(), BaseInfo); + CharUnits Align = getNaturalPointeeTypeAlignment(E->getType(), BaseInfo, + TBAAInfo); return Address(EmitScalarExpr(E), Align); } @@ -2447,8 +2460,10 @@ LValue CodeGenFunction::EmitUnaryOpLValu assert(!T.isNull() && "CodeGenFunction::EmitUnaryOpL
r315739 - Revert "[CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info", r315731.
Author: kosarev Date: Fri Oct 13 12:55:01 2017 New Revision: 315739 URL: http://llvm.org/viewvc/llvm-project?rev=315739&view=rev Log: Revert "[CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info", r315731. With this change we fail on the clang-x86_64-linux-selfhost-modules builder. Differential Revision: https://reviews.llvm.org/D38796 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315739&r1=315738&r2=315739&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 13 12:55:01 2017 @@ -916,8 +916,7 @@ void CodeGenModule::EmitExplicitCastExpr /// EmitPointerWithAlignment - Given an expression of pointer type, try to /// derive a more accurate bound on the alignment of the pointer. Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E, - LValueBaseInfo *BaseInfo, - TBAAAccessInfo *TBAAInfo) { + LValueBaseInfo *BaseInfo) { // We allow this with ObjC object pointers because of fragile ABIs. assert(E->getType()->isPointerType() || E->getType()->isObjCObjectPointerType()); @@ -937,28 +936,19 @@ Address CodeGenFunction::EmitPointerWith if (PtrTy->getPointeeType()->isVoidType()) break; -LValueBaseInfo InnerBaseInfo; -TBAAAccessInfo InnerTBAAInfo; -Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), -&InnerBaseInfo, -&InnerTBAAInfo); -if (BaseInfo) *BaseInfo = InnerBaseInfo; -if (TBAAInfo) *TBAAInfo = InnerTBAAInfo; +LValueBaseInfo InnerInfo; +Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), &InnerInfo); +if (BaseInfo) *BaseInfo = InnerInfo; // If this is an explicit bitcast, and the source l-value is // opaque, honor the alignment of the casted-to type. if (isa(CE) && -InnerBaseInfo.getAlignmentSource() != AlignmentSource::Decl) { - LValueBaseInfo TargetTypeBaseInfo; - TBAAAccessInfo TargetTypeTBAAInfo; +InnerInfo.getAlignmentSource() != AlignmentSource::Decl) { + LValueBaseInfo ExpInfo; CharUnits Align = getNaturalPointeeTypeAlignment(E->getType(), - &TargetTypeBaseInfo, - &TargetTypeTBAAInfo); + &ExpInfo); if (BaseInfo) -BaseInfo->mergeForCast(TargetTypeBaseInfo); - if (TBAAInfo) -*TBAAInfo = CGM.mergeTBAAInfoForCast(*TBAAInfo, - TargetTypeTBAAInfo); +BaseInfo->mergeForCast(ExpInfo); Addr = Address(Addr.getPointer(), Align); } @@ -979,13 +969,12 @@ Address CodeGenFunction::EmitPointerWith // Array-to-pointer decay. case CK_ArrayToPointerDecay: - return EmitArrayToPointerDecay(CE->getSubExpr(), BaseInfo, TBAAInfo); + return EmitArrayToPointerDecay(CE->getSubExpr(), BaseInfo); // Derived-to-base conversions. case CK_UncheckedDerivedToBase: case CK_DerivedToBase: { - Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo, - TBAAInfo); + Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo); auto Derived = CE->getSubExpr()->getType()->getPointeeCXXRecordDecl(); return GetAddressOfBaseClass(Addr, Derived, CE->path_begin(), CE->path_end(), @@ -1005,7 +994,6 @@ Address CodeGenFunction::EmitPointerWith if (UO->getOpcode() == UO_AddrOf) { LValue LV = EmitLValue(UO->getSubExpr()); if (BaseInfo) *BaseInfo = LV.getBaseInfo(); - if (TBAAInfo) *TBAAInfo = LV.getTBAAInfo(); return LV.getAddress(); } } @@ -1013,8 +1001,7 @@ Address CodeGenFunction::EmitPointerWith // TODO: conditional operators, comma. // Otherwise, use the alignment of the type. - CharUnits Align = getNaturalPointeeTypeAlignment(E->getType(), BaseInfo, - TBAAInfo); + CharUnits Align = getNaturalPointeeTypeAlignment(E->getType(), BaseInfo); return Address(EmitScalarExpr(E), Align); } @@ -2460,10 +2447,8 @@ L
r315984 - [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info
Author: kosarev Date: Tue Oct 17 02:12:13 2017 New Revision: 315984 URL: http://llvm.org/viewvc/llvm-project?rev=315984&view=rev Log: [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info Differential Revision: https://reviews.llvm.org/D38796 Added: cfe/trunk/test/CodeGen/tbaa-cast.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315984&r1=315983&r2=315984&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Oct 17 02:12:13 2017 @@ -916,7 +916,8 @@ void CodeGenModule::EmitExplicitCastExpr /// EmitPointerWithAlignment - Given an expression of pointer type, try to /// derive a more accurate bound on the alignment of the pointer. Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E, - LValueBaseInfo *BaseInfo) { + LValueBaseInfo *BaseInfo, + TBAAAccessInfo *TBAAInfo) { // We allow this with ObjC object pointers because of fragile ABIs. assert(E->getType()->isPointerType() || E->getType()->isObjCObjectPointerType()); @@ -936,20 +937,30 @@ Address CodeGenFunction::EmitPointerWith if (PtrTy->getPointeeType()->isVoidType()) break; -LValueBaseInfo InnerInfo; -Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), &InnerInfo); -if (BaseInfo) *BaseInfo = InnerInfo; - -// If this is an explicit bitcast, and the source l-value is -// opaque, honor the alignment of the casted-to type. -if (isa(CE) && -InnerInfo.getAlignmentSource() != AlignmentSource::Decl) { - LValueBaseInfo ExpInfo; +LValueBaseInfo InnerBaseInfo; +TBAAAccessInfo InnerTBAAInfo; +Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), +&InnerBaseInfo, +&InnerTBAAInfo); +if (BaseInfo) *BaseInfo = InnerBaseInfo; +if (TBAAInfo) *TBAAInfo = InnerTBAAInfo; + +if (isa(CE)) { + LValueBaseInfo TargetTypeBaseInfo; + TBAAAccessInfo TargetTypeTBAAInfo; CharUnits Align = getNaturalPointeeTypeAlignment(E->getType(), - &ExpInfo); - if (BaseInfo) -BaseInfo->mergeForCast(ExpInfo); - Addr = Address(Addr.getPointer(), Align); + &TargetTypeBaseInfo, + &TargetTypeTBAAInfo); + if (TBAAInfo) +*TBAAInfo = CGM.mergeTBAAInfoForCast(*TBAAInfo, + TargetTypeTBAAInfo); + // If the source l-value is opaque, honor the alignment of the + // casted-to type. + if (InnerBaseInfo.getAlignmentSource() != AlignmentSource::Decl) { +if (BaseInfo) + BaseInfo->mergeForCast(TargetTypeBaseInfo); +Addr = Address(Addr.getPointer(), Align); + } } if (SanOpts.has(SanitizerKind::CFIUnrelatedCast) && @@ -969,12 +980,13 @@ Address CodeGenFunction::EmitPointerWith // Array-to-pointer decay. case CK_ArrayToPointerDecay: - return EmitArrayToPointerDecay(CE->getSubExpr(), BaseInfo); + return EmitArrayToPointerDecay(CE->getSubExpr(), BaseInfo, TBAAInfo); // Derived-to-base conversions. case CK_UncheckedDerivedToBase: case CK_DerivedToBase: { - Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo); + Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo, + TBAAInfo); auto Derived = CE->getSubExpr()->getType()->getPointeeCXXRecordDecl(); return GetAddressOfBaseClass(Addr, Derived, CE->path_begin(), CE->path_end(), @@ -994,6 +1006,7 @@ Address CodeGenFunction::EmitPointerWith if (UO->getOpcode() == UO_AddrOf) { LValue LV = EmitLValue(UO->getSubExpr()); if (BaseInfo) *BaseInfo = LV.getBaseInfo(); + if (TBAAInfo) *TBAAInfo = LV.getTBAAInfo(); return LV.getAddress(); } } @@ -1001,7 +1014,8 @@ Address CodeGenFunction::EmitPointerWith // TODO: conditional operators, comma. // Otherwise, use the alignment of the type. - CharUnits Align = getNaturalPointeeTypeAlignme
r315986 - [CodeGen] Pass TBAA info along with lvalue base info everywhere
Author: kosarev Date: Tue Oct 17 03:17:43 2017 New Revision: 315986 URL: http://llvm.org/viewvc/llvm-project?rev=315986&view=rev Log: [CodeGen] Pass TBAA info along with lvalue base info everywhere This patch addresses the rest of the cases where we pass lvalue base info, but do not provide corresponding TBAA info. This patch should not bring in any functional changes. This is part of D38126 reworked to be a separate patch to make reviewing easier. Differential Revision: https://reviews.llvm.org/D38945 Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp cfe/trunk/lib/CodeGen/CGValue.h cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=315986&r1=315985&r2=315986&view=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Tue Oct 17 03:17:43 2017 @@ -96,9 +96,8 @@ namespace { BFI.StorageSize = AtomicSizeInBits; BFI.StorageOffset += OffsetInChars; LVal = LValue::MakeBitfield(Address(Addr, lvalue.getAlignment()), -BFI, lvalue.getType(), -lvalue.getBaseInfo()); -LVal.setTBAAInfo(lvalue.getTBAAInfo()); +BFI, lvalue.getType(), lvalue.getBaseInfo(), +lvalue.getTBAAInfo()); AtomicTy = C.getIntTypeForBitwidth(AtomicSizeInBits, OrigBFI.IsSigned); if (AtomicTy.isNull()) { llvm::APInt Size( @@ -1346,15 +1345,15 @@ RValue AtomicInfo::convertAtomicTempToRV if (LVal.isBitField()) return CGF.EmitLoadOfBitfieldLValue( LValue::MakeBitfield(addr, LVal.getBitFieldInfo(), LVal.getType(), - LVal.getBaseInfo()), loc); + LVal.getBaseInfo(), TBAAAccessInfo()), loc); if (LVal.isVectorElt()) return CGF.EmitLoadOfLValue( LValue::MakeVectorElt(addr, LVal.getVectorIdx(), LVal.getType(), - LVal.getBaseInfo()), loc); + LVal.getBaseInfo(), TBAAAccessInfo()), loc); assert(LVal.isExtVectorElt()); return CGF.EmitLoadOfExtVectorElementLValue(LValue::MakeExtVectorElt( addr, LVal.getExtVectorElts(), LVal.getType(), - LVal.getBaseInfo())); + LVal.getBaseInfo(), TBAAAccessInfo())); } RValue AtomicInfo::ConvertIntToValueOrAtomic(llvm::Value *IntVal, @@ -1670,29 +1669,30 @@ EmitAtomicUpdateValue(CodeGenFunction &C UpdateLVal = LValue::MakeBitfield(Ptr, AtomicLVal.getBitFieldInfo(), AtomicLVal.getType(), - AtomicLVal.getBaseInfo()); + AtomicLVal.getBaseInfo(), + AtomicLVal.getTBAAInfo()); DesiredLVal = LValue::MakeBitfield(DesiredAddr, AtomicLVal.getBitFieldInfo(), - AtomicLVal.getType(), - AtomicLVal.getBaseInfo()); + AtomicLVal.getType(), AtomicLVal.getBaseInfo(), + AtomicLVal.getTBAAInfo()); } else if (AtomicLVal.isVectorElt()) { UpdateLVal = LValue::MakeVectorElt(Ptr, AtomicLVal.getVectorIdx(), AtomicLVal.getType(), - AtomicLVal.getBaseInfo()); + AtomicLVal.getBaseInfo(), + AtomicLVal.getTBAAInfo()); DesiredLVal = LValue::MakeVectorElt( DesiredAddr, AtomicLVal.getVectorIdx(), AtomicLVal.getType(), - AtomicLVal.getBaseInfo()); + AtomicLVal.getBaseInfo(), AtomicLVal.getTBAAInfo()); } else { assert(AtomicLVal.isExtVectorElt()); UpdateLVal = LValue::MakeExtVectorElt(Ptr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), -AtomicLVal.getBaseInfo()); +AtomicLVal.getBaseInfo(), +AtomicLVal.getTBAAInfo()); DesiredLVal = LValue::MakeExtVectorElt( DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(), - AtomicLVal.getBaseInfo()); + AtomicLVal.getBaseInfo(), AtomicLVal.getTBAAInfo()); } -UpdateLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); -DesiredLVal.setTBAAInfo(AtomicLVal.getTBAAInfo()); UpRVal = CGF.EmitLoadOfLValue(UpdateLVal, SourceLocation()); } // Store new value in the corresponding memory area @@ -1775,20 +1775,19 @@ static void EmitAtomicUpdateValue(CodeGe if (AtomicLVal.isBitField()) { DesiredLVal =
r315989 - [CodeGen] Refine generation of TBAA info for bit-field lvalues
Author: kosarev Date: Tue Oct 17 04:20:19 2017 New Revision: 315989 URL: http://llvm.org/viewvc/llvm-project?rev=315989&view=rev Log: [CodeGen] Refine generation of TBAA info for bit-field lvalues The main change is that now we generate TBAA info before constructing the resulting lvalue instead of constructing lvalue with some default TBAA info and fixing it as necessary afterwards. We also keep the TBAA info close to lvalue base info, which is supposed to simplify their future merging. This patch should not bring in any functional changes. This is part of D38126 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38947 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315989&r1=315988&r2=315989&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Oct 17 04:20:19 2017 @@ -3679,15 +3679,6 @@ static bool hasAnyVptr(const QualType Ty LValue CodeGenFunction::EmitLValueForField(LValue base, const FieldDecl *field) { LValueBaseInfo BaseInfo = base.getBaseInfo(); - AlignmentSource fieldAlignSource = -getFieldAlignmentSource(BaseInfo.getAlignmentSource()); - LValueBaseInfo FieldBaseInfo(fieldAlignSource, BaseInfo.getMayAlias()); - - QualType type = field->getType(); - const RecordDecl *rec = field->getParent(); - if (rec->isUnion() || rec->hasAttr() || type->isVectorType()) -FieldBaseInfo.setMayAlias(true); - bool mayAlias = FieldBaseInfo.getMayAlias(); if (field->isBitField()) { const CGRecordLayout &RL = @@ -3707,20 +3698,55 @@ LValue CodeGenFunction::EmitLValueForFie QualType fieldType = field->getType().withCVRQualifiers(base.getVRQualifiers()); +// TODO: Support TBAA for bit fields. +LValueBaseInfo FieldBaseInfo(BaseInfo.getAlignmentSource(), false); return LValue::MakeBitfield(Addr, Info, fieldType, FieldBaseInfo, TBAAAccessInfo()); } + // Fields of may-alias structures are may-alias themselves. + // FIXME: this should get propagated down through anonymous structs + // and unions. + QualType FieldType = field->getType(); + const RecordDecl *rec = field->getParent(); + AlignmentSource BaseAlignSource = BaseInfo.getAlignmentSource(); + LValueBaseInfo FieldBaseInfo(getFieldAlignmentSource(BaseAlignSource), false); + TBAAAccessInfo FieldTBAAInfo; + if (BaseInfo.getMayAlias() || rec->hasAttr() || + FieldType->isVectorType()) { +FieldBaseInfo.setMayAlias(true); +FieldTBAAInfo = CGM.getTBAAMayAliasAccessInfo(); + } else if (rec->isUnion()) { +// TODO: Support TBAA for unions. +FieldBaseInfo.setMayAlias(true); +FieldTBAAInfo = CGM.getTBAAMayAliasAccessInfo(); + } else { +// If no base type been assigned for the base access, then try to generate +// one for this base lvalue. +FieldTBAAInfo = base.getTBAAInfo(); +if (!FieldTBAAInfo.BaseType) { +FieldTBAAInfo.BaseType = CGM.getTBAABaseTypeInfo(base.getType()); +assert(!FieldTBAAInfo.Offset && + "Nonzero offset for an access with no base type!"); +} + +// Adjust offset to be relative to the base type. +const ASTRecordLayout &Layout = +getContext().getASTRecordLayout(field->getParent()); +unsigned CharWidth = getContext().getCharWidth(); +if (FieldTBAAInfo.BaseType) + FieldTBAAInfo.Offset += + Layout.getFieldOffset(field->getFieldIndex()) / CharWidth; + +// Update the final access type. +FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType); + } + Address addr = base.getAddress(); unsigned cvr = base.getVRQualifiers(); - bool TBAAPath = CGM.getCodeGenOpts().StructPathTBAA; if (rec->isUnion()) { // For unions, there is no pointer adjustment. -assert(!type->isReferenceType() && "union has reference member"); -// TODO: handle path-aware TBAA for union. -TBAAPath = false; - -const auto FieldType = field->getType(); +assert(!FieldType->isReferenceType() && "union has reference member"); if (CGM.getCodeGenOpts().StrictVTablePointers && hasAnyVptr(FieldType, getContext())) // Because unions can easily skip invariant.barriers, we need to add @@ -3732,24 +3758,17 @@ LValue CodeGenFunction::EmitLValueForFie addr = emitAddrOfFieldStorage(*this, addr, field); // If this is a reference field, load the reference right now. -if (const ReferenceType *refType = type->getAs()) { +if (const ReferenceType *refType = FieldType->getAs()) { llvm::LoadInst *load = Builder.CreateLoad(addr, "ref"); if (cvr & Qualifiers::Volatile) load->setVolatile(true); - // Loading the reference will disable path-aware TBAA. - TBAAPath = false
r316211 - [CodeGen] Fix generation of TBAA info for array-to-pointer conversions
Author: kosarev Date: Fri Oct 20 05:35:17 2017 New Revision: 316211 URL: http://llvm.org/viewvc/llvm-project?rev=316211&view=rev Log: [CodeGen] Fix generation of TBAA info for array-to-pointer conversions Resolves: Fatal error: Offset not zero at the point of scalar access. http://llvm.org/PR34992 Differential Revision: https://reviews.llvm.org/D39083 Added: cfe/trunk/test/CodeGen/tbaa-array.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=316211&r1=316210&r2=316211&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 20 05:35:17 2017 @@ -3072,8 +3072,6 @@ Address CodeGenFunction::EmitArrayToPoin // Expressions of array type can't be bitfields or vector elements. LValue LV = EmitLValue(E); Address Addr = LV.getAddress(); - if (BaseInfo) *BaseInfo = LV.getBaseInfo(); - if (TBAAInfo) *TBAAInfo = LV.getTBAAInfo(); // If the array type was an incomplete type, we need to make sure // the decay ends up being the right type. @@ -3088,7 +3086,15 @@ Address CodeGenFunction::EmitArrayToPoin Addr = Builder.CreateStructGEP(Addr, 0, CharUnits::Zero(), "arraydecay"); } + // The result of this decay conversion points to an array element within the + // base lvalue. However, since TBAA currently does not support representing + // accesses to elements of member arrays, we conservatively represent accesses + // to the pointee object as if it had no any base lvalue specified. + // TODO: Support TBAA for member arrays. QualType EltType = E->getType()->castAsArrayTypeUnsafe()->getElementType(); + if (BaseInfo) *BaseInfo = LV.getBaseInfo(); + if (TBAAInfo) *TBAAInfo = CGM.getTBAAAccessInfo(EltType); + return Builder.CreateElementBitCast(Addr, ConvertTypeForMem(EltType)); } Added: cfe/trunk/test/CodeGen/tbaa-array.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-array.cpp?rev=316211&view=auto == --- cfe/trunk/test/CodeGen/tbaa-array.cpp (added) +++ cfe/trunk/test/CodeGen/tbaa-array.cpp Fri Oct 20 05:35:17 2017 @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \ +// RUN: -emit-llvm -o - | FileCheck %s +// +// Check that we generate correct TBAA information for accesses to array +// elements. + +struct A { int i; }; +struct B { A a[1]; }; + +int foo(B *b) { +// CHECK-LABEL: _Z3fooP1B +// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_i:!.*]] + return b->a->i; +} + +// CHECK-DAG: [[TAG_A_i]] = !{[[TYPE_A:!.*]], [[TYPE_int:!.*]], i64 0} +// CHECK-DAG: [[TYPE_A]] = !{!"_ZTS1A", !{{.*}}, i64 0} +// CHECK-DAG: [[TYPE_int]] = !{!"int", !{{.*}}, i64 0} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337690 - [NEON] Fix support for vrndi_f32(), vrndiq_f32() and vrndns_f32() intrinsics
Author: kosarev Date: Mon Jul 23 06:26:37 2018 New Revision: 337690 URL: http://llvm.org/viewvc/llvm-project?rev=337690&view=rev Log: [NEON] Fix support for vrndi_f32(), vrndiq_f32() and vrndns_f32() intrinsics This patch adds support for vrndi_f32() and vrndiq_f32() intrinsics in AArch32 mode and for vrndns_f32() intrinsic in AArch64 mode. Differential Revision: https://reviews.llvm.org/D48829 Modified: cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/aarch64-neon-misc.c cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c cfe/trunk/test/CodeGen/arm64-vrnd.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=337690&r1=337689&r2=337690&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Mon Jul 23 06:26:37 2018 @@ -988,6 +988,7 @@ def FRINTP_S32 : SInst<"vrndp", "dd", "f def FRINTM_S32 : SInst<"vrndm", "dd", "fQf">; def FRINTX_S32 : SInst<"vrndx", "dd", "fQf">; def FRINTZ_S32 : SInst<"vrnd", "dd", "fQf">; +def FRINTI_S32 : SInst<"vrndi", "dd", "fQf">; } let ArchGuard = "__ARM_ARCH >= 8 && defined(__aarch64__) && defined(__ARM_FEATURE_DIRECTED_ROUNDING)" in { @@ -997,7 +998,7 @@ def FRINTP_S64 : SInst<"vrndp", "dd", "d def FRINTM_S64 : SInst<"vrndm", "dd", "dQd">; def FRINTX_S64 : SInst<"vrndx", "dd", "dQd">; def FRINTZ_S64 : SInst<"vrnd", "dd", "dQd">; -def FRINTI_S64 : SInst<"vrndi", "dd", "fdQfQd">; +def FRINTI_S64 : SInst<"vrndi", "dd", "dQd">; } Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=337690&r1=337689&r2=337690&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jul 23 06:26:37 2018 @@ -4158,6 +4158,8 @@ static const NeonIntrinsicInfo ARMSIMDIn NEONMAP1(vrnd_v, arm_neon_vrintz, Add1ArgType), NEONMAP1(vrnda_v, arm_neon_vrinta, Add1ArgType), NEONMAP1(vrndaq_v, arm_neon_vrinta, Add1ArgType), + NEONMAP0(vrndi_v), + NEONMAP0(vrndiq_v), NEONMAP1(vrndm_v, arm_neon_vrintm, Add1ArgType), NEONMAP1(vrndmq_v, arm_neon_vrintm, Add1ArgType), NEONMAP1(vrndn_v, arm_neon_vrintn, Add1ArgType), @@ -4334,6 +4336,8 @@ static const NeonIntrinsicInfo AArch64SI NEONMAP1(vrecpsq_v, aarch64_neon_frecps, Add1ArgType), NEONMAP2(vrhadd_v, aarch64_neon_urhadd, aarch64_neon_srhadd, Add1ArgType | UnsignedAlts), NEONMAP2(vrhaddq_v, aarch64_neon_urhadd, aarch64_neon_srhadd, Add1ArgType | UnsignedAlts), + NEONMAP0(vrndi_v), + NEONMAP0(vrndiq_v), NEONMAP2(vrshl_v, aarch64_neon_urshl, aarch64_neon_srshl, Add1ArgType | UnsignedAlts), NEONMAP2(vrshlq_v, aarch64_neon_urshl, aarch64_neon_srshl, Add1ArgType | UnsignedAlts), NEONMAP2(vrshr_n_v, aarch64_neon_urshl, aarch64_neon_srshl, UnsignedAlts), @@ -5094,7 +5098,10 @@ Value *CodeGenFunction::EmitCommonNeonBu case NEON::BI__builtin_neon_vrsqrteq_v: Int = Ty->isFPOrFPVectorTy() ? LLVMIntrinsic : AltLLVMIntrinsic; return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, NameHint); - + case NEON::BI__builtin_neon_vrndi_v: + case NEON::BI__builtin_neon_vrndiq_v: +Int = Intrinsic::nearbyint; +return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, NameHint); case NEON::BI__builtin_neon_vrshr_n_v: case NEON::BI__builtin_neon_vrshrq_n_v: return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vrshr_n", @@ -7486,11 +7493,6 @@ Value *CodeGenFunction::EmitAArch64Built Int = Intrinsic::nearbyint; return EmitNeonCall(CGM.getIntrinsic(Int, HalfTy), Ops, "vrndi"); } - case NEON::BI__builtin_neon_vrndi_v: - case NEON::BI__builtin_neon_vrndiq_v: { -Int = Intrinsic::nearbyint; -return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vrndi"); - } case NEON::BI__builtin_neon_vrndmh_f16: { Ops.push_back(EmitScalarExpr(E->getArg(0))); Int = Intrinsic::floor; @@ -7511,6 +7513,11 @@ Value *CodeGenFunction::EmitAArch64Built Int = Intrinsic::aarch64_neon_frintn; return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vrndn"); } + case NEON::BI__builtin_neon_vrndns_f32: { +Ops.push_back(EmitScalarExpr(E->getArg(0))); +Int = Intrinsic::aarch64_neon_frintn; +return EmitNeonCall(CGM.getIntrinsic(Int, FloatTy), Ops, "vrndn"); + } case NEON::BI__builtin_neon_vrndph_f16: { Ops.push_back(EmitScalarExpr(E->getArg(0))); Int = Intrinsic::ceil; Modified: cfe/trunk/test/CodeGen/aarch64-neon-misc.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-misc.c?rev=337690&r1=337689&r2=337690&view=diff ===
r337699 - [NEON] Define half-precision vrnd intrinsics only when available
Author: kosarev Date: Mon Jul 23 07:53:44 2018 New Revision: 337699 URL: http://llvm.org/viewvc/llvm-project?rev=337699&view=rev Log: [NEON] Define half-precision vrnd intrinsics only when available Differential Revision: https://reviews.llvm.org/D49376 Modified: cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/test/Sema/arm-no-fp16.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=337699&r1=337698&r2=337699&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Mon Jul 23 07:53:44 2018 @@ -1417,12 +1417,14 @@ let ArchGuard = "defined(__ARM_FEATURE_F def VCVTP_U16: SInst<"vcvtp_u16", "ud", "hQh">; // Vector rounding - def FRINTZH : SInst<"vrnd", "dd", "hQh">; - def FRINTNH : SInst<"vrndn", "dd", "hQh">; - def FRINTAH : SInst<"vrnda", "dd", "hQh">; - def FRINTPH : SInst<"vrndp", "dd", "hQh">; - def FRINTMH : SInst<"vrndm", "dd", "hQh">; - def FRINTXH : SInst<"vrndx", "dd", "hQh">; + let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_DIRECTED_ROUNDING) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)" in { +def FRINTZH : SInst<"vrnd", "dd", "hQh">; +def FRINTNH : SInst<"vrndn", "dd", "hQh">; +def FRINTAH : SInst<"vrnda", "dd", "hQh">; +def FRINTPH : SInst<"vrndp", "dd", "hQh">; +def FRINTMH : SInst<"vrndm", "dd", "hQh">; +def FRINTXH : SInst<"vrndx", "dd", "hQh">; + } // Misc. def VABSH: SInst<"vabs", "dd", "hQh">; Modified: cfe/trunk/test/Sema/arm-no-fp16.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/arm-no-fp16.c?rev=337699&r1=337698&r2=337699&view=diff == --- cfe/trunk/test/Sema/arm-no-fp16.c (original) +++ cfe/trunk/test/Sema/arm-no-fp16.c Mon Jul 23 07:53:44 2018 @@ -9,3 +9,59 @@ float16x4_t test_vcvt_f16_f32(float32x4_ float32x4_t test_vcvt_f32_f16(float16x4_t a) { return vcvt_f32_f16(a); // expected-warning{{implicit declaration of function 'vcvt_f32_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float32x4_t'}} } + +float16x4_t test_vrnda_f16(float16x4_t a) { + return vrnda_f16(a); // expected-warning{{implicit declaration of function 'vrnda_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}} +} + +float16x8_t test_vrndaq_f16(float16x8_t a) { + return vrndaq_f16(a); // expected-warning{{implicit declaration of function 'vrndaq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}} +} + +float16x4_t test_vrnd_f16(float16x4_t a) { + return vrnd_f16(a); // expected-warning{{implicit declaration of function 'vrnd_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}} +} + +float16x8_t test_vrndq_f16(float16x8_t a) { + return vrndq_f16(a); // expected-warning{{implicit declaration of function 'vrndq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}} +} + +float16x4_t test_vrndi_f16(float16x4_t a) { + return vrndi_f16(a); // expected-warning{{implicit declaration of function 'vrndi_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}} +} + +float16x8_t test_vrndiq_f16(float16x8_t a) { + return vrndiq_f16(a); // expected-warning{{implicit declaration of function 'vrndiq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}} +} + +float16x4_t test_vrndm_f16(float16x4_t a) { + return vrndm_f16(a); // expected-warning{{implicit declaration of function 'vrndm_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}} +} + +float16x8_t test_vrndmq_f16(float16x8_t a) { + return vrndmq_f16(a); // expected-warning{{implicit declaration of function 'vrndmq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}} +} + +float16x4_t test_vrndn_f16(float16x4_t a) { + return vrndn_f16(a); // expected-warning{{implicit declaration of function 'vrndn_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}} +} + +float16x8_t test_vrndnq_f16(float16x8_t a) { + return vrndnq_f16(a); // expected-warning{{implicit declaration of function 'vrndnq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}} +} + +float16x4_t test_vrndp_f16(float16x4_t a) { + return vrndp_f16(a); // expected-warning{{implicit declaration of function 'vrndp_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}} +} + +floa
r337704 - [NEON] Define half-precision vmaxnm intrinsics only when available
Author: kosarev Date: Mon Jul 23 09:01:35 2018 New Revision: 337704 URL: http://llvm.org/viewvc/llvm-project?rev=337704&view=rev Log: [NEON] Define half-precision vmaxnm intrinsics only when available Differential Revision: https://reviews.llvm.org/D49375 Modified: cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/test/Sema/arm-no-fp16.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=337704&r1=337703&r2=337704&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Mon Jul 23 09:01:35 2018 @@ -1466,8 +1466,10 @@ let ArchGuard = "defined(__ARM_FEATURE_F // Max/Min def VMAXH : SInst<"vmax", "ddd", "hQh">; def VMINH : SInst<"vmin", "ddd", "hQh">; - def FMAXNMH : SInst<"vmaxnm", "ddd", "hQh">; - def FMINNMH : SInst<"vminnm", "ddd", "hQh">; + let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_NUMERIC_MAXMIN) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)" in { +def FMAXNMH : SInst<"vmaxnm", "ddd", "hQh">; +def FMINNMH : SInst<"vminnm", "ddd", "hQh">; + } // Multiplication/Division def VMULH : SOpInst<"vmul", "ddd", "hQh", OP_MUL>; Modified: cfe/trunk/test/Sema/arm-no-fp16.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/arm-no-fp16.c?rev=337704&r1=337703&r2=337704&view=diff == --- cfe/trunk/test/Sema/arm-no-fp16.c (original) +++ cfe/trunk/test/Sema/arm-no-fp16.c Mon Jul 23 09:01:35 2018 @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon -target-feature -fp16 -fsyntax-only -verify +// RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon \ +// RUN: -fallow-half-arguments-and-returns -target-feature -fp16 \ +// RUN: -fsyntax-only -verify #include @@ -65,3 +67,19 @@ float16x4_t test_vrndx_f16(float16x4_t a float16x8_t test_vrndxq_f16(float16x8_t a) { return vrndxq_f16(a); // expected-warning{{implicit declaration of function 'vrndxq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}} } + +float16x4_t test_vmaxnm_f16(float16x4_t a, float16x4_t b) { + return vmaxnm_f16(a, b); // expected-warning{{implicit declaration of function 'vmaxnm_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}} +} + +float16x8_t test_vmaxnmq_f16(float16x8_t a, float16x8_t b) { + return vmaxnmq_f16(a, b); // expected-warning{{implicit declaration of function 'vmaxnmq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}} +} + +float16x4_t test_vminnm_f16(float16x4_t a, float16x4_t b) { + return vminnm_f16(a, b); // expected-warning{{implicit declaration of function 'vminnm_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}} +} + +float16x8_t test_vminnmq_f16(float16x8_t a, float16x8_t b) { + return vminnmq_f16(a, b); // expected-warning{{implicit declaration of function 'vminnmq_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float16x8_t'}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r325120 - [AST] Refine the condition for element-dependent array fillers
Author: kosarev Date: Wed Feb 14 05:10:35 2018 New Revision: 325120 URL: http://llvm.org/viewvc/llvm-project?rev=325120&view=rev Log: [AST] Refine the condition for element-dependent array fillers This patch fixes clang to not consider braced initializers for aggregate elements of arrays to be potentially dependent on the indices of the initialized elements. Resolves bug 18978: initialize a large static array = clang oom? https://bugs.llvm.org/show_bug.cgi?id=18978 Differential Revision: https://reviews.llvm.org/D43187 Added: cfe/trunk/test/SemaCXX/large-array-init.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=325120&r1=325119&r2=325120&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Feb 14 05:10:35 2018 @@ -48,6 +48,8 @@ #include #include +#define DEBUG_TYPE "exprconstant" + using namespace clang; using llvm::APSInt; using llvm::APFloat; @@ -6780,6 +6782,22 @@ static bool EvaluateArray(const Expr *E, return ArrayExprEvaluator(Info, This, Result).Visit(E); } +// Return true iff the given array filler may depend on the element index. +static bool MaybeElementDependentArrayFiller(const Expr *FillerExpr) { + // For now, just whitelist non-class value-initialization and initialization + // lists comprised of them. + if (isa(FillerExpr)) +return false; + if (const InitListExpr *ILE = dyn_cast(FillerExpr)) { +for (unsigned I = 0, E = ILE->getNumInits(); I != E; ++I) { + if (MaybeElementDependentArrayFiller(ILE->getInit(I))) +return true; +} +return false; + } + return true; +} + bool ArrayExprEvaluator::VisitInitListExpr(const InitListExpr *E) { const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(E->getType()); if (!CAT) @@ -6809,10 +6827,13 @@ bool ArrayExprEvaluator::VisitInitListEx const Expr *FillerExpr = E->hasArrayFiller() ? E->getArrayFiller() : nullptr; // If the initializer might depend on the array index, run it for each - // array element. For now, just whitelist non-class value-initialization. - if (NumEltsToInit != NumElts && !isa(FillerExpr)) + // array element. + if (NumEltsToInit != NumElts && MaybeElementDependentArrayFiller(FillerExpr)) NumEltsToInit = NumElts; + DEBUG(llvm::dbgs() << "The number of elements to initialize: " << +NumEltsToInit << ".\n"); + Result = APValue(APValue::UninitArray(), NumEltsToInit, NumElts); // If the array was previously zero-initialized, preserve the Added: cfe/trunk/test/SemaCXX/large-array-init.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/large-array-init.cpp?rev=325120&view=auto == --- cfe/trunk/test/SemaCXX/large-array-init.cpp (added) +++ cfe/trunk/test/SemaCXX/large-array-init.cpp Wed Feb 14 05:10:35 2018 @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -S -o %t.ll -mllvm -debug-only=exprconstant %s 2>&1 | \ +// RUN: FileCheck %s + +struct S { int i; }; + +static struct S arr[1] = {{ 0 }}; +// CHECK: The number of elements to initialize: 1. + +struct S *foo() { return arr; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r325123 - [AST] Fix passing large-array-init.cpp on builds without asserts
Author: kosarev Date: Wed Feb 14 05:27:48 2018 New Revision: 325123 URL: http://llvm.org/viewvc/llvm-project?rev=325123&view=rev Log: [AST] Fix passing large-array-init.cpp on builds without asserts Differential Revision: https://reviews.llvm.org/D43187 Modified: cfe/trunk/test/SemaCXX/large-array-init.cpp Modified: cfe/trunk/test/SemaCXX/large-array-init.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/large-array-init.cpp?rev=325123&r1=325122&r2=325123&view=diff == --- cfe/trunk/test/SemaCXX/large-array-init.cpp (original) +++ cfe/trunk/test/SemaCXX/large-array-init.cpp Wed Feb 14 05:27:48 2018 @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -S -o %t.ll -mllvm -debug-only=exprconstant %s 2>&1 | \ // RUN: FileCheck %s +// REQUIRES: asserts struct S { int i; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r325478 - [CodeGen] Initialize large arrays by copying from a global
Author: kosarev Date: Mon Feb 19 01:49:11 2018 New Revision: 325478 URL: http://llvm.org/viewvc/llvm-project?rev=325478&view=rev Log: [CodeGen] Initialize large arrays by copying from a global Currently, clang compiles explicit initializers for array elements into series of store instructions. For large arrays of built-in types this results in bloated output code and significant amount of time spent on the instruction selection phase. This patch fixes the issue by initializing such arrays with global constants that store the binary image of the initializer. Differential Revision: https://reviews.llvm.org/D43181 Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/test/CodeGen/init.c Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=325478&r1=325477&r2=325478&view=diff == --- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Mon Feb 19 01:49:11 2018 @@ -14,6 +14,7 @@ #include "CodeGenFunction.h" #include "CGObjCRuntime.h" #include "CodeGenModule.h" +#include "ConstantEmitter.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclTemplate.h" @@ -85,7 +86,7 @@ public: void EmitMoveFromReturnSlot(const Expr *E, RValue Src); void EmitArrayInit(Address DestPtr, llvm::ArrayType *AType, - QualType elementType, InitListExpr *E); + QualType ArrayQTy, InitListExpr *E); AggValueSlot::NeedsGCBarriers_t needsGC(QualType T) { if (CGF.getLangOpts().getGC() && TypeRequiresGCollection(T)) @@ -394,12 +395,15 @@ static bool isTrivialFiller(Expr *E) { /// \brief Emit initialization of an array from an initializer list. void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType, - QualType elementType, InitListExpr *E) { + QualType ArrayQTy, InitListExpr *E) { uint64_t NumInitElements = E->getNumInits(); uint64_t NumArrayElements = AType->getNumElements(); assert(NumInitElements <= NumArrayElements); + QualType elementType = + CGF.getContext().getAsArrayType(ArrayQTy)->getElementType(); + // DestPtr is an array*. Construct an elementType* by drilling // down a level. llvm::Value *zero = llvm::ConstantInt::get(CGF.SizeTy, 0); @@ -411,6 +415,29 @@ void AggExprEmitter::EmitArrayInit(Addre CharUnits elementAlign = DestPtr.getAlignment().alignmentOfArrayElement(elementSize); + // Consider initializing the array by copying from a global. For this to be + // more efficient than per-element initialization, the size of the elements + // with explicit initializers should be large enough. + if (NumInitElements * elementSize.getQuantity() > 16 && + elementType.isTriviallyCopyableType(CGF.getContext())) { +CodeGen::CodeGenModule &CGM = CGF.CGM; +ConstantEmitter Emitter(CGM); +LangAS AS = ArrayQTy.getAddressSpace(); +if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) { + auto GV = new llvm::GlobalVariable( + CGM.getModule(), C->getType(), + CGM.isTypeConstant(ArrayQTy, /* ExcludeCtorDtor= */ true), + llvm::GlobalValue::PrivateLinkage, C, "constinit", + /* InsertBefore= */ nullptr, llvm::GlobalVariable::NotThreadLocal, + CGM.getContext().getTargetAddressSpace(AS)); + Emitter.finalize(GV); + CharUnits Align = CGM.getContext().getTypeAlignInChars(ArrayQTy); + GV->setAlignment(Align.getQuantity()); + EmitFinalDestCopy(ArrayQTy, CGF.MakeAddrLValue(GV, ArrayQTy, Align)); + return; +} + } + // Exception safety requires us to destroy all the // already-constructed members if an initializer throws. // For that, we'll need an EH cleanup. @@ -1158,11 +1185,8 @@ void AggExprEmitter::VisitInitListExpr(I // Handle initialization of an array. if (E->getType()->isArrayType()) { -QualType elementType = -CGF.getContext().getAsArrayType(E->getType())->getElementType(); - auto AType = cast(Dest.getAddress().getElementType()); -EmitArrayInit(Dest.getAddress(), AType, elementType, E); +EmitArrayInit(Dest.getAddress(), AType, E->getType(), E); return; } Modified: cfe/trunk/test/CodeGen/init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/init.c?rev=325478&r1=325477&r2=325478&view=diff == --- cfe/trunk/test/CodeGen/init.c (original) +++ cfe/trunk/test/CodeGen/init.c Mon Feb 19 01:49:11 2018 @@ -8,8 +8,9 @@ unsigned v2[2][3] = {[0 ... 1][0 ... 1] // CHECK-DAG: %struct.M = type { [2 x %struct.I] } // CHECK-DAG: %struct.I = type { [3 x i32] } -// CHECK: [1 x %struct.M] [%struct.M { [2 x %struct.I] [%struct.I { [3 x i32] [i32 4, i32 4, i32 0] }, %struct.I { [3 x i32] [
r325575 - [CodeGen] Fix generation of TBAA tags for may-alias accesses
Author: kosarev Date: Tue Feb 20 04:33:04 2018 New Revision: 325575 URL: http://llvm.org/viewvc/llvm-project?rev=325575&view=rev Log: [CodeGen] Fix generation of TBAA tags for may-alias accesses This patch fixes creating TBAA access descriptors for may_alias-marked access types. Currently, for such types we generate ordinary descriptors with char as its access type. The patch changes this to produce proper may-alias descriptors. Differential Revision: https://reviews.llvm.org/D42366 Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h cfe/trunk/test/CodeGen/may-alias.c Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=325575&r1=325574&r2=325575&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Feb 20 04:33:04 2018 @@ -602,13 +602,9 @@ llvm::MDNode *CodeGenModule::getTBAAType } TBAAAccessInfo CodeGenModule::getTBAAAccessInfo(QualType AccessType) { - // Pointee values may have incomplete types, but they shall never be - // dereferenced. - if (AccessType->isIncompleteType()) -return TBAAAccessInfo::getIncompleteInfo(); - - uint64_t Size = Context.getTypeSizeInChars(AccessType).getQuantity(); - return TBAAAccessInfo(getTBAATypeInfo(AccessType), Size); + if (!TBAA) +return TBAAAccessInfo(); + return TBAA->getAccessInfo(AccessType); } TBAAAccessInfo Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=325575&r1=325574&r2=325575&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Tue Feb 20 04:33:04 2018 @@ -215,6 +215,19 @@ llvm::MDNode *CodeGenTBAA::getTypeInfo(Q return MetadataCache[Ty] = TypeNode; } +TBAAAccessInfo CodeGenTBAA::getAccessInfo(QualType AccessType) { + // Pointee values may have incomplete types, but they shall never be + // dereferenced. + if (AccessType->isIncompleteType()) +return TBAAAccessInfo::getIncompleteInfo(); + + if (TypeHasMayAlias(AccessType)) +return TBAAAccessInfo::getMayAliasInfo(); + + uint64_t Size = Context.getTypeSizeInChars(AccessType).getQuantity(); + return TBAAAccessInfo(getTypeInfo(AccessType), Size); +} + TBAAAccessInfo CodeGenTBAA::getVTablePtrAccessInfo(llvm::Type *VTablePtrType) { llvm::DataLayout DL(&Module); unsigned Size = DL.getPointerTypeSize(VTablePtrType); Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.h?rev=325575&r1=325574&r2=325575&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenTBAA.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.h Tue Feb 20 04:33:04 2018 @@ -177,6 +177,10 @@ public: /// given type. llvm::MDNode *getTypeInfo(QualType QTy); + /// getAccessInfo - Get TBAA information that describes an access to + /// an object of the given type. + TBAAAccessInfo getAccessInfo(QualType AccessType); + /// getVTablePtrAccessInfo - Get the TBAA information that describes an /// access to a virtual table pointer. TBAAAccessInfo getVTablePtrAccessInfo(llvm::Type *VTablePtrType); Modified: cfe/trunk/test/CodeGen/may-alias.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/may-alias.c?rev=325575&r1=325574&r2=325575&view=diff == --- cfe/trunk/test/CodeGen/may-alias.c (original) +++ cfe/trunk/test/CodeGen/may-alias.c Tue Feb 20 04:33:04 2018 @@ -1,18 +1,24 @@ -// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -no-struct-path-tbaa -disable-llvm-passes -o - %s | FileCheck %s -// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-passes -o - %s | FileCheck %s -check-prefix=PATH +// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 \ +// RUN: -no-struct-path-tbaa -disable-llvm-passes -o - %s | \ +// RUN: FileCheck %s -check-prefixes=CHECK,SCALAR +// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 \ +// RUN: -disable-llvm-passes -o - %s | \ +// RUN: FileCheck %s -check-prefixes=CHECK,OLD-PATH +// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 \ +// RUN: -new-struct-path-tbaa -disable-llvm-passes -o - %s | \ +// RUN: FileCheck %s -check-prefixes=CHECK,NEW-PATH // Types with the may_alias attribute should be considered equivalent // to char for aliasing. typedef int __attribute__((may_alias)) aliasing_int; -void test0(aliasing_int *ai, int *i) -{ -// CHECK: store i32 0, i32* %{{.*}}, !tbaa [[TAG_CHA
r320994 - Fix the reference to the now renamed member of TBAAStructField
Author: kosarev Date: Mon Dec 18 08:50:11 2017 New Revision: 320994 URL: http://llvm.org/viewvc/llvm-project?rev=320994&view=rev Log: Fix the reference to the now renamed member of TBAAStructField See https://reviews.llvm.org/D39956 for details. Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=320994&r1=320993&r2=320994&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Mon Dec 18 08:50:11 2017 @@ -306,7 +306,7 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeIn // Create the struct type node with a vector of pairs (offset, type). SmallVector, 4> OffsetsAndTypes; for (const auto &Field : Fields) -OffsetsAndTypes.push_back(std::make_pair(Field.TBAA, Field.Offset)); +OffsetsAndTypes.push_back(std::make_pair(Field.Type, Field.Offset)); return MDHelper.createTBAAStructTypeNode(OutName, OffsetsAndTypes); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r321250 - [CodeGen] Fix access sizes in new-format TBAA tags
Author: kosarev Date: Thu Dec 21 00:14:16 2017 New Revision: 321250 URL: http://llvm.org/viewvc/llvm-project?rev=321250&view=rev Log: [CodeGen] Fix access sizes in new-format TBAA tags The new format requires to specify both the type of the access and its size. This patch fixes setting access sizes for TBAA tags that denote accesses to structure members. This fix affects all future TBAA metadata tests for the new format, so I guess we don't need any special tests for this fix. Differential Revision: https://reviews.llvm.org/D41452 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=321250&r1=321249&r2=321250&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Dec 21 00:14:16 2017 @@ -3801,8 +3801,10 @@ LValue CodeGenFunction::EmitLValueForFie FieldTBAAInfo.Offset += Layout.getFieldOffset(field->getFieldIndex()) / CharWidth; -// Update the final access type. +// Update the final access type and size. FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType); +FieldTBAAInfo.Size = +getContext().getTypeSizeInChars(FieldType).getQuantity(); } Address addr = base.getAddress(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r321351 - [CodeGen] Support generation of TBAA info in the new format
Author: kosarev Date: Fri Dec 22 01:54:23 2017 New Revision: 321351 URL: http://llvm.org/viewvc/llvm-project?rev=321351&view=rev Log: [CodeGen] Support generation of TBAA info in the new format Now that the MDBuilder helpers generating TBAA type and access descriptors in the new format are in place, we can teach clang to use them when requested. Differential Revision: https://reviews.llvm.org/D41394 Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/test/CodeGen/tbaa.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=321351&r1=321350&r2=321351&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Fri Dec 22 01:54:23 2017 @@ -59,7 +59,10 @@ llvm::MDNode *CodeGenTBAA::getRoot() { llvm::MDNode *CodeGenTBAA::createScalarTypeNode(StringRef Name, llvm::MDNode *Parent, uint64_t Size) { - (void)Size; // TODO: Support generation of size-aware type nodes. + if (CodeGenOpts.NewStructPathTBAA) { +llvm::Metadata *Id = MDHelper.createString(Name); +return MDHelper.createTBAATypeNode(Parent, Size, Id); + } return MDHelper.createTBAAScalarTypeNode(Name, Parent); } @@ -300,8 +303,12 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeIn OutName = RD->getName(); } -// TODO: Support size-aware type nodes and create one here for the -// given aggregate type. +if (CodeGenOpts.NewStructPathTBAA) { + llvm::MDNode *Parent = getChar(); + uint64_t Size = Context.getTypeSizeInChars(Ty).getQuantity(); + llvm::Metadata *Id = MDHelper.createString(OutName); + return MDHelper.createTBAATypeNode(Parent, Size, Id, Fields); +} // Create the struct type node with a vector of pairs (offset, type). SmallVector, 4> OffsetsAndTypes; @@ -348,6 +355,10 @@ llvm::MDNode *CodeGenTBAA::getAccessTagI Info.BaseType = Info.AccessType; assert(!Info.Offset && "Nonzero offset for an access with no base type!"); } + if (CodeGenOpts.NewStructPathTBAA) { +return N = MDHelper.createTBAAAccessTag(Info.BaseType, Info.AccessType, +Info.Offset, Info.Size); + } return N = MDHelper.createTBAAStructTagNode(Info.BaseType, Info.AccessType, Info.Offset); } Modified: cfe/trunk/test/CodeGen/tbaa.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa.cpp?rev=321351&r1=321350&r2=321351&view=diff == --- cfe/trunk/test/CodeGen/tbaa.cpp (original) +++ cfe/trunk/test/CodeGen/tbaa.cpp Fri Dec 22 01:54:23 2017 @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -no-struct-path-tbaa -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefix=PATH +// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefixes=PATH,OLD-PATH +// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -new-struct-path-tbaa -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefixes=PATH,NEW-PATH // RUN: %clang_cc1 -triple x86_64-apple-darwin -O0 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -relaxed-aliasing -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA // Test TBAA metadata generated by front-end. @@ -248,29 +249,57 @@ uint32_t g15(StructS *S, StructS3 *S3, u // CHECK: [[TYPE_i16]] = !{!"short", [[TYPE_char]], // CHECK: [[TAG_char]] = !{[[TYPE_char]], [[TYPE_char]], i64 0} -// PATH: [[TYPE_CHAR:!.*]] = !{!"omnipotent char", ! -// PATH: [[TAG_i32]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0} -// PATH: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]] -// PATH: [[TAG_A_f32]] = !{[[TYPE_A:!.*]], [[TYPE_INT]], i64 4} -// PATH: [[TYPE_A]] = !{!"_ZTS7StructA", [[TYPE_SHORT:!.*]], i64 0, [[TYPE_INT]], i64 4, [[TYPE_SHORT]], i64 8, [[TYPE_INT]], i64 12} -// PATH: [[TYPE_SHORT:!.*]] = !{!"short", [[TYPE_CHAR]] -// PATH: [[TAG_A_f16]] = !{[[TYPE_A]], [[TYPE_SHORT]], i64 0} -// PATH: [[TAG_B_a_f32]] = !{[[TYPE_B:!.*]], [[TYPE_INT]], i64 8} -// PATH: [[TYPE_B]] = !{!"_ZTS7StructB", [[TYPE_SHORT]], i64 0, [[TYPE_A]], i64 4, [[TYPE_INT]], i64 20} -// PATH: [[TAG_B_a_f16]] = !{[[TYPE_B]], [[TYPE_SHORT]], i64 4} -// PATH: [[TAG_B_f32]] = !{[[TYPE_B]], [[TYPE_INT]], i64 20} -// PATH: [[TAG_B_a_f32_2]] = !{[[TYPE_B]], [[TYPE_INT]], i64 16} -// PATH: [[TAG_S_f32]] = !{[[TYPE_S:!.*]], [[TYPE_INT]], i64 4} -// PATH: [[TYPE_S]] = !{!"_ZTS7StructS", [[TYPE_SHORT]], i64 0, [[TYPE_INT]], i64 4} -// PATH: [[TAG_S_f16]]
r321352 - [CodeGen] Represent array members in new-format TBAA type descriptors
Author: kosarev Date: Fri Dec 22 01:57:24 2017 New Revision: 321352 URL: http://llvm.org/viewvc/llvm-project?rev=321352&view=rev Log: [CodeGen] Represent array members in new-format TBAA type descriptors Now that in the new TBAA format we allow access types to be of any object types, including aggregate ones, it becomes critical to specify types of all sub-objects such aggregates comprise as their members. In order to meet this requirement, this patch enables generation of field descriptors for members of array types. Differential Revision: https://reviews.llvm.org/D41399 Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/test/CodeGen/tbaa-array.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=321352&r1=321351&r2=321352&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Fri Dec 22 01:57:24 2017 @@ -161,6 +161,10 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHe if (Ty->isPointerType() || Ty->isReferenceType()) return createScalarTypeNode("any pointer", getChar(), Size); + // Accesses to arrays are accesses to objects of their element types. + if (CodeGenOpts.NewStructPathTBAA && Ty->isArrayType()) +return getTypeInfo(cast(Ty)->getElementType()); + // Enum types are distinct types. In C++ they have "underlying types", // however they aren't related for TBAA. if (const EnumType *ETy = dyn_cast(Ty)) { Modified: cfe/trunk/test/CodeGen/tbaa-array.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-array.cpp?rev=321352&r1=321351&r2=321352&view=diff == --- cfe/trunk/test/CodeGen/tbaa-array.cpp (original) +++ cfe/trunk/test/CodeGen/tbaa-array.cpp Fri Dec 22 01:57:24 2017 @@ -1,18 +1,52 @@ // RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \ // RUN: -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \ +// RUN: -new-struct-path-tbaa -emit-llvm -o - | \ +// RUN: FileCheck -check-prefix=CHECK-NEW %s // // Check that we generate correct TBAA information for accesses to array // elements. struct A { int i; }; struct B { A a[1]; }; +struct C { int i; int x[3]; }; int foo(B *b) { // CHECK-LABEL: _Z3fooP1B // CHECK: load i32, {{.*}}, !tbaa [[TAG_A_i:!.*]] +// CHECK-NEW-LABEL: _Z3fooP1B +// CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_A_i:!.*]] return b->a->i; } +// Check that members of array types are represented correctly. +int bar(C *c) { +// CHECK-NEW-LABEL: _Z3barP1C +// CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_C_i:!.*]] + return c->i; +} + +int bar2(C *c) { +// CHECK-NEW-LABEL: _Z4bar2P1C +// CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]] + return c->x[2]; +} + +int bar3(C *c, int j) { +// CHECK-NEW-LABEL: _Z4bar3P1Ci +// CHECK-NEW: load i32, {{.*}}, !tbaa [[TAG_int:!.*]] + return c->x[j]; +} + // CHECK-DAG: [[TAG_A_i]] = !{[[TYPE_A:!.*]], [[TYPE_int:!.*]], i64 0} // CHECK-DAG: [[TYPE_A]] = !{!"_ZTS1A", !{{.*}}, i64 0} // CHECK-DAG: [[TYPE_int]] = !{!"int", !{{.*}}, i64 0} + +// CHECK-NEW-DAG: [[TYPE_char:!.*]] = !{{{.*}}, i64 1, !"omnipotent char"} +// CHECK-NEW-DAG: [[TYPE_int:!.*]] = !{[[TYPE_char]], i64 4, !"int"} +// CHECK-NEW-DAG: [[TAG_int]] = !{[[TYPE_int]], [[TYPE_int]], i64 0, i64 4} +// CHECK-NEW-DAG: [[TYPE_pointer:!.*]] = !{[[TYPE_char]], i64 8, !"any pointer"} +// CHECK-NEW-DAG: [[TYPE_A:!.*]] = !{[[TYPE_char]], i64 4, !"_ZTS1A", [[TYPE_int]], i64 0, i64 4} +// CHECK-NEW-DAG: [[TAG_A_i]] = !{[[TYPE_A]], [[TYPE_int]], i64 0, i64 4} +// CHECK-NEW-DAG: [[TYPE_C:!.*]] = !{[[TYPE_char]], i64 16, !"_ZTS1C", [[TYPE_int]], i64 0, i64 4, [[TYPE_int]], i64 4, i64 12} +// CHECK-NEW-DAG: [[TAG_C_i]] = !{[[TYPE_C:!.*]], [[TYPE_int:!.*]], i64 0, i64 4} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r321999 - [CodeGen] Fix TBAA info for accesses to members of base classes
Author: kosarev Date: Mon Jan 8 07:36:06 2018 New Revision: 321999 URL: http://llvm.org/viewvc/llvm-project?rev=321999&view=rev Log: [CodeGen] Fix TBAA info for accesses to members of base classes Resolves: Bug 35724 - regression (r315984): fatal error: error in backend: Broken function found (Did not see access type in access path!) https://bugs.llvm.org/show_bug.cgi?id=35724 Differential Revision: https://reviews.llvm.org/D41547 Added: cfe/trunk/test/CodeGen/tbaa-base.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=321999&r1=321998&r2=321999&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Jan 8 07:36:06 2018 @@ -1034,8 +1034,12 @@ Address CodeGenFunction::EmitPointerWith // Derived-to-base conversions. case CK_UncheckedDerivedToBase: case CK_DerivedToBase: { - Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo, - TBAAInfo); + // TODO: Support accesses to members of base classes in TBAA. For now, we + // conservatively pretend that the complete object is of the base class + // type. + if (TBAAInfo) +*TBAAInfo = CGM.getTBAAAccessInfo(E->getType()); + Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo); auto Derived = CE->getSubExpr()->getType()->getPointeeCXXRecordDecl(); return GetAddressOfBaseClass(Addr, Derived, CE->path_begin(), CE->path_end(), Added: cfe/trunk/test/CodeGen/tbaa-base.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-base.cpp?rev=321999&view=auto == --- cfe/trunk/test/CodeGen/tbaa-base.cpp (added) +++ cfe/trunk/test/CodeGen/tbaa-base.cpp Mon Jan 8 07:36:06 2018 @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 %s -emit-llvm -o - | FileCheck %s +// +// Test generating of TBAA metadata for accesses to members of base classes. + +struct A { + int x, y, z; +}; + +struct B : A { + int i; +}; + +struct C { + int i; + B b; + int j; +}; + +int f1(B *b) { +// CHECK-LABEL: _Z2f1P1B +// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y:!.*]] + return b->y; +} + +int f2(C *c) { +// CHECK-LABEL: _Z2f2P1C +// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]] + return (&(c->b))->y; +} + +struct D : virtual A +{}; + +struct E { + D d; +}; + +int f3(D *d) { +// CHECK-LABEL: _Z2f3P1D +// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]] + return d->y; +} + +int f4(E *e) { +// CHECK-LABEL: _Z2f4P1E +// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]] + return (&(e->d))->y; +} + +// CHECK-DAG: [[TYPE_char:!.*]] = !{!"omnipotent char", {{.*}}, i64 0} +// CHECK-DAG: [[TYPE_int:!.*]] = !{!"int", [[TYPE_char]], i64 0} +// CHECK-DAG: [[TYPE_A:!.*]] = !{!"_ZTS1A", [[TYPE_int]], i64 0, [[TYPE_int]], i64 4, [[TYPE_int]], i64 8} +// CHECK-DAG: [[TAG_A_y]] = !{[[TYPE_A]], [[TYPE_int]], i64 4} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330012 - [NEON] Support vrndns_f32 intrinsic
Author: kosarev Date: Fri Apr 13 05:46:02 2018 New Revision: 330012 URL: http://llvm.org/viewvc/llvm-project?rev=330012&view=rev Log: [NEON] Support vrndns_f32 intrinsic Differential Revision: https://reviews.llvm.org/D45515 Modified: cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=330012&r1=330011&r2=330012&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Fri Apr 13 05:46:02 2018 @@ -1116,6 +1116,12 @@ def SCALAR_FCVTZU_N_U64 : SInst<"vcvt_n_ } +// Scalar Floating-point Round to Integral +let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_DIRECTED_ROUNDING)" in { +def SCALAR_FRINTN_S32 : SInst<"vrndn", "ss", "Sf">; +} + + // Scalar Reduce Pairwise Addition (Scalar and Floating Point) def SCALAR_ADDP : SInst<"vpadd", "sd", "SfSHlSHdSHUl">; Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=330012&r1=330011&r2=330012&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Apr 13 05:46:02 2018 @@ -5590,6 +5590,12 @@ Value *CodeGenFunction::EmitARMBuiltinEx case NEON::BI__builtin_neon_vgetq_lane_f32: return Builder.CreateExtractElement(Ops[0], Ops[1], "vget_lane"); + case NEON::BI__builtin_neon_vrndns_f32: { +Value *Arg = EmitScalarExpr(E->getArg(0)); +llvm::Type *Tys[] = {Arg->getType()}; +Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vrintn, Tys); +return Builder.CreateCall(F, {Arg}, "vrndn"); } + case NEON::BI__builtin_neon_vset_lane_i8: case NEON::BI__builtin_neon_vset_lane_i16: case NEON::BI__builtin_neon_vset_lane_i32: Modified: cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c?rev=330012&r1=330011&r2=330012&view=diff == --- cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c (original) +++ cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c Fri Apr 13 05:46:02 2018 @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck %s +// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \ +// RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \ +// RUN: opt -S -mem2reg | FileCheck %s #include @@ -85,3 +87,10 @@ float32x2_t test_vrnd_f32(float32x2_t a) float32x4_t test_vrndq_f32(float32x4_t a) { return vrndq_f32(a); } + +// CHECK-LABEL: define float @test_vrndns_f32(float %a) #0 { +// CHECK: [[VRNDN_I:%.*]] = call float @llvm.arm.neon.vrintn.f32(float %a) #2 +// CHECK: ret float [[VRNDN_I]] +float32_t test_vrndns_f32(float32_t a) { + return vrndns_f32(a); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330187 - [NEON] Fix the architecture condition for the crypto intrinsics
Author: kosarev Date: Tue Apr 17 06:37:30 2018 New Revision: 330187 URL: http://llvm.org/viewvc/llvm-project?rev=330187&view=rev Log: [NEON] Fix the architecture condition for the crypto intrinsics Differential Revision: https://reviews.llvm.org/D45669 Modified: cfe/trunk/include/clang/Basic/arm_neon.td Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=330187&r1=330186&r2=330187&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Tue Apr 17 06:37:30 2018 @@ -913,7 +913,7 @@ def VEXT_A64 : WInst<"vext", "dddi", "dQ // Crypto -let ArchGuard = "__ARM_FEATURE_CRYPTO" in { +let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_CRYPTO)" in { def AESE : SInst<"vaese", "ddd", "QUc">; def AESD : SInst<"vaesd", "ddd", "QUc">; def AESMC : SInst<"vaesmc", "dd", "QUc">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330195 - [NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only
Author: kosarev Date: Tue Apr 17 09:43:07 2018 New Revision: 330195 URL: http://llvm.org/viewvc/llvm-project?rev=330195&view=rev Log: [NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only Differential Revision: https://reviews.llvm.org/D45668 Modified: cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/test/CodeGen/arm_neon_intrinsics.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=330195&r1=330194&r2=330195&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Tue Apr 17 09:43:07 2018 @@ -398,8 +398,14 @@ def VCOMBINE : NoTestOpInst<"vcombine", // E.3.21 Splitting vectors let InstName = "vmov" in { -def VGET_HIGH : NoTestOpInst<"vget_high", "dk", "csilhfUcUsUiUlPcPs", OP_HI>; -def VGET_LOW : NoTestOpInst<"vget_low", "dk", "csilhfUcUsUiUlPcPs", OP_LO>; +def VGET_HIGH : NoTestOpInst<"vget_high", "dk", "csilfUcUsUiUlPcPs", OP_HI>; +def VGET_LOW : NoTestOpInst<"vget_low", "dk", "csilfUcUsUiUlPcPs", OP_LO>; +} +let ArchGuard = "__ARM_ARCH >= 8 && defined(__aarch64__)" in { + let InstName = "vmov" in { + def VGET_HIGH_F16 : NoTestOpInst<"vget_high", "dk", "h", OP_HI>; + def VGET_LOW_F16 : NoTestOpInst<"vget_low", "dk", "h", OP_LO>; + } } Modified: cfe/trunk/test/CodeGen/arm_neon_intrinsics.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm_neon_intrinsics.c?rev=330195&r1=330194&r2=330195&view=diff == --- cfe/trunk/test/CodeGen/arm_neon_intrinsics.c (original) +++ cfe/trunk/test/CodeGen/arm_neon_intrinsics.c Tue Apr 17 09:43:07 2018 @@ -3254,13 +3254,6 @@ int64x1_t test_vget_high_s64(int64x2_t a return vget_high_s64(a); } -// CHECK-LABEL: @test_vget_high_f16( -// CHECK: [[SHUFFLE_I:%.*]] = shufflevector <8 x half> %a, <8 x half> %a, <4 x i32> -// CHECK: ret <4 x half> [[SHUFFLE_I]] -float16x4_t test_vget_high_f16(float16x8_t a) { - return vget_high_f16(a); -} - // CHECK-LABEL: @test_vget_high_f32( // CHECK: [[SHUFFLE_I:%.*]] = shufflevector <4 x float> %a, <4 x float> %a, <2 x i32> // CHECK: ret <2 x float> [[SHUFFLE_I]] @@ -3560,13 +3553,6 @@ int64x1_t test_vget_low_s64(int64x2_t a) return vget_low_s64(a); } -// CHECK-LABEL: @test_vget_low_f16( -// CHECK: [[SHUFFLE_I:%.*]] = shufflevector <8 x half> %a, <8 x half> %a, <4 x i32> -// CHECK: ret <4 x half> [[SHUFFLE_I]] -float16x4_t test_vget_low_f16(float16x8_t a) { - return vget_low_f16(a); -} - // CHECK-LABEL: @test_vget_low_f32( // CHECK: [[SHUFFLE_I:%.*]] = shufflevector <4 x float> %a, <4 x float> %a, <2 x i32> // CHECK: ret <2 x float> [[SHUFFLE_I]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330248 - Revert r330195 "[NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only".
Author: kosarev Date: Wed Apr 18 05:02:49 2018 New Revision: 330248 URL: http://llvm.org/viewvc/llvm-project?rev=330248&view=rev Log: Revert r330195 "[NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only". Differential Revision: https://reviews.llvm.org/D45668 Modified: cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/test/CodeGen/arm_neon_intrinsics.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=330248&r1=330247&r2=330248&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Wed Apr 18 05:02:49 2018 @@ -398,14 +398,8 @@ def VCOMBINE : NoTestOpInst<"vcombine", // E.3.21 Splitting vectors let InstName = "vmov" in { -def VGET_HIGH : NoTestOpInst<"vget_high", "dk", "csilfUcUsUiUlPcPs", OP_HI>; -def VGET_LOW : NoTestOpInst<"vget_low", "dk", "csilfUcUsUiUlPcPs", OP_LO>; -} -let ArchGuard = "__ARM_ARCH >= 8 && defined(__aarch64__)" in { - let InstName = "vmov" in { - def VGET_HIGH_F16 : NoTestOpInst<"vget_high", "dk", "h", OP_HI>; - def VGET_LOW_F16 : NoTestOpInst<"vget_low", "dk", "h", OP_LO>; - } +def VGET_HIGH : NoTestOpInst<"vget_high", "dk", "csilhfUcUsUiUlPcPs", OP_HI>; +def VGET_LOW : NoTestOpInst<"vget_low", "dk", "csilhfUcUsUiUlPcPs", OP_LO>; } Modified: cfe/trunk/test/CodeGen/arm_neon_intrinsics.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm_neon_intrinsics.c?rev=330248&r1=330247&r2=330248&view=diff == --- cfe/trunk/test/CodeGen/arm_neon_intrinsics.c (original) +++ cfe/trunk/test/CodeGen/arm_neon_intrinsics.c Wed Apr 18 05:02:49 2018 @@ -3254,6 +3254,13 @@ int64x1_t test_vget_high_s64(int64x2_t a return vget_high_s64(a); } +// CHECK-LABEL: @test_vget_high_f16( +// CHECK: [[SHUFFLE_I:%.*]] = shufflevector <8 x half> %a, <8 x half> %a, <4 x i32> +// CHECK: ret <4 x half> [[SHUFFLE_I]] +float16x4_t test_vget_high_f16(float16x8_t a) { + return vget_high_f16(a); +} + // CHECK-LABEL: @test_vget_high_f32( // CHECK: [[SHUFFLE_I:%.*]] = shufflevector <4 x float> %a, <4 x float> %a, <2 x i32> // CHECK: ret <2 x float> [[SHUFFLE_I]] @@ -3553,6 +3560,13 @@ int64x1_t test_vget_low_s64(int64x2_t a) return vget_low_s64(a); } +// CHECK-LABEL: @test_vget_low_f16( +// CHECK: [[SHUFFLE_I:%.*]] = shufflevector <8 x half> %a, <8 x half> %a, <4 x i32> +// CHECK: ret <4 x half> [[SHUFFLE_I]] +float16x4_t test_vget_low_f16(float16x8_t a) { + return vget_low_f16(a); +} + // CHECK-LABEL: @test_vget_low_f32( // CHECK: [[SHUFFLE_I:%.*]] = shufflevector <4 x float> %a, <4 x float> %a, <2 x i32> // CHECK: ret <2 x float> [[SHUFFLE_I]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330336 - [NEON] Define vfma_n_f32() and vfmaq_n_f32() intrinsics in AArch32 mode
Author: kosarev Date: Thu Apr 19 08:27:28 2018 New Revision: 330336 URL: http://llvm.org/viewvc/llvm-project?rev=330336&view=rev Log: [NEON] Define vfma_n_f32() and vfmaq_n_f32() intrinsics in AArch32 mode Differential Revision: https://reviews.llvm.org/D45670 Modified: cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/test/CodeGen/arm-neon-fma.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=330336&r1=330335&r2=330336&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Thu Apr 19 08:27:28 2018 @@ -531,6 +531,7 @@ def VREINTERPRET let ArchGuard = "defined(__ARM_FEATURE_FMA)" in { def VFMA : SInst<"vfma", "", "fQf">; def VFMS : SOpInst<"vfms", "", "fQf", OP_FMLS>; + def FMLA_N_F32 : SOpInst<"vfma_n", "ddds", "fQf", OP_FMLA_N>; } @@ -621,7 +622,7 @@ def FMLS : SOpInst<"vfms", "", "dQd" // MUL, MLA, MLS, FMA, FMS definitions with scalar argument def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>; -def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>; +def FMLA_N : SOpInst<"vfma_n", "ddds", "dQd", OP_FMLA_N>; def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>; def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>; Modified: cfe/trunk/test/CodeGen/arm-neon-fma.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-neon-fma.c?rev=330336&r1=330335&r2=330336&view=diff == --- cfe/trunk/test/CodeGen/arm-neon-fma.c (original) +++ cfe/trunk/test/CodeGen/arm-neon-fma.c Thu Apr 19 08:27:28 2018 @@ -20,3 +20,27 @@ float32x2_t test_fma_order(float32x2_t a float32x4_t test_fmaq_order(float32x4_t accum, float32x4_t lhs, float32x4_t rhs) { return vfmaq_f32(accum, lhs, rhs); } + +// CHECK-LABEL: define <2 x float> @test_vfma_n_f32(<2 x float> %a, <2 x float> %b, float %n) #0 { +// CHECK: [[VECINIT_I:%.*]] = insertelement <2 x float> undef, float %n, i32 0 +// CHECK: [[VECINIT1_I:%.*]] = insertelement <2 x float> [[VECINIT_I]], float %n, i32 1 +// CHECK: [[TMP1:%.*]] = bitcast <2 x float> %b to <8 x i8> +// CHECK: [[TMP2:%.*]] = bitcast <2 x float> [[VECINIT1_I]] to <8 x i8> +// CHECK: [[TMP3:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> %b, <2 x float> [[VECINIT1_I]], <2 x float> %a) +// CHECK: ret <2 x float> [[TMP3]] +float32x2_t test_vfma_n_f32(float32x2_t a, float32x2_t b, float32_t n) { + return vfma_n_f32(a, b, n); +} + +// CHECK-LABEL: define <4 x float> @test_vfmaq_n_f32(<4 x float> %a, <4 x float> %b, float %n) #0 { +// CHECK: [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0 +// CHECK: [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], float %n, i32 1 +// CHECK: [[VECINIT2_I:%.*]] = insertelement <4 x float> [[VECINIT1_I]], float %n, i32 2 +// CHECK: [[VECINIT3_I:%.*]] = insertelement <4 x float> [[VECINIT2_I]], float %n, i32 3 +// CHECK: [[TMP1:%.*]] = bitcast <4 x float> %b to <16 x i8> +// CHECK: [[TMP2:%.*]] = bitcast <4 x float> [[VECINIT3_I]] to <16 x i8> +// CHECK: [[TMP3:%.*]] = call <4 x float> @llvm.fma.v4f32(<4 x float> %b, <4 x float> [[VECINIT3_I]], <4 x float> %a) +// CHECK: ret <4 x float> [[TMP3]] +float32x4_t test_vfmaq_n_f32(float32x4_t a, float32x4_t b, float32_t n) { + return vfmaq_n_f32(a, b, n); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330420 - [NEON] Add a comment explaining the situation with vget_high_f16() and vget_low_f16() intrinsics
Author: kosarev Date: Fri Apr 20 05:09:25 2018 New Revision: 330420 URL: http://llvm.org/viewvc/llvm-project?rev=330420&view=rev Log: [NEON] Add a comment explaining the situation with vget_high_f16() and vget_low_f16() intrinsics Related differential revision: https://reviews.llvm.org/D45668 Modified: cfe/trunk/include/clang/Basic/arm_neon.td Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=330420&r1=330419&r2=330420&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Fri Apr 20 05:09:25 2018 @@ -397,6 +397,10 @@ def VCOMBINE : NoTestOpInst<"vcombine", // E.3.21 Splitting vectors +// Note that the ARM NEON Reference 2.0 mistakenly document the vget_high_f16() +// and vget_low_f16() intrinsics as AArch64-only. We (and GCC) support all +// versions of these intrinsics in both AArch32 and AArch64 architectures. See +// D45668 for more details. let InstName = "vmov" in { def VGET_HIGH : NoTestOpInst<"vget_high", "dk", "csilhfUcUsUiUlPcPs", OP_HI>; def VGET_LOW : NoTestOpInst<"vget_low", "dk", "csilhfUcUsUiUlPcPs", OP_LO>; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r319012 - [CodeGen] Collect information about sizes of accesses and access types for TBAA
Author: kosarev Date: Mon Nov 27 01:39:29 2017 New Revision: 319012 URL: http://llvm.org/viewvc/llvm-project?rev=319012&view=rev Log: [CodeGen] Collect information about sizes of accesses and access types for TBAA The information about access and type sizes is necessary for producing TBAA metadata in the new size-aware format. With this patch, D39955 and D39956 in place we should be able to change CodeGenTBAA::createScalarTypeNode() and CodeGenTBAA::getBaseTypeInfo() to generate metadata in the new format under the -new-struct-path-tbaa command-line option. For now, this new information remains unused. Differential Revision: https://reviews.llvm.org/D40176 Modified: cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=319012&r1=319011&r2=319012&view=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Nov 27 01:39:29 2017 @@ -2423,7 +2423,8 @@ void CodeGenFunction::InitializeVTablePo VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy); llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField); - CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAVTablePtrAccessInfo()); + TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy); + CGM.DecorateInstructionWithTBAA(Store, TBAAInfo); if (CGM.getCodeGenOpts().OptimizationLevel > 0 && CGM.getCodeGenOpts().StrictVTablePointers) CGM.DecorateInstructionWithInvariantGroup(Store, Vptr.VTableClass); @@ -2517,7 +2518,8 @@ llvm::Value *CodeGenFunction::GetVTableP const CXXRecordDecl *RD) { Address VTablePtrSrc = Builder.CreateElementBitCast(This, VTableTy); llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc, "vtable"); - CGM.DecorateInstructionWithTBAA(VTable, CGM.getTBAAVTablePtrAccessInfo()); + TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTableTy); + CGM.DecorateInstructionWithTBAA(VTable, TBAAInfo); if (CGM.getCodeGenOpts().OptimizationLevel > 0 && CGM.getCodeGenOpts().StrictVTablePointers) Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=319012&r1=319011&r2=319012&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Nov 27 01:39:29 2017 @@ -136,7 +136,7 @@ CodeGenModule::CodeGenModule(ASTContext // Enable TBAA unless it's suppressed. ThreadSanitizer needs TBAA even at O0. if (LangOpts.Sanitize.has(SanitizerKind::Thread) || (!CodeGenOpts.RelaxedAliasing && CodeGenOpts.OptimizationLevel > 0)) -TBAA.reset(new CodeGenTBAA(Context, VMContext, CodeGenOpts, getLangOpts(), +TBAA.reset(new CodeGenTBAA(Context, TheModule, CodeGenOpts, getLangOpts(), getCXXABI().getMangleContext())); // If debug info or coverage generation is enabled, create the CGDebugInfo @@ -579,13 +579,20 @@ llvm::MDNode *CodeGenModule::getTBAAType } TBAAAccessInfo CodeGenModule::getTBAAAccessInfo(QualType AccessType) { - return TBAAAccessInfo(getTBAATypeInfo(AccessType)); + // Pointee values may have incomplete types, but they shall never be + // dereferenced. + if (AccessType->isIncompleteType()) +return TBAAAccessInfo::getIncompleteInfo(); + + uint64_t Size = Context.getTypeSizeInChars(AccessType).getQuantity(); + return TBAAAccessInfo(getTBAATypeInfo(AccessType), Size); } -TBAAAccessInfo CodeGenModule::getTBAAVTablePtrAccessInfo() { +TBAAAccessInfo +CodeGenModule::getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType) { if (!TBAA) return TBAAAccessInfo(); - return TBAA->getVTablePtrAccessInfo(); + return TBAA->getVTablePtrAccessInfo(VTablePtrType); } llvm::MDNode *CodeGenModule::getTBAAStructInfo(QualType QTy) { Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=319012&r1=319011&r2=319012&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Nov 27 01:39:29 2017 @@ -664,7 +664,7 @@ public: /// getTBAAVTablePtrAccessInfo - Get the TBAA information that describes an /// access to a virtual table pointer. - TBAAAccessInfo getTBAAVTablePtrAccessInfo(); + TBAAAccessInfo getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType); llvm::MDNode *getTBAAStructInfo(QualType QTy); Modified: cfe/trunk/lib/CodeGen/CodeG
r319413 - [CodeGen] Add initial support for union members in TBAA
Author: kosarev Date: Thu Nov 30 01:26:39 2017 New Revision: 319413 URL: http://llvm.org/viewvc/llvm-project?rev=319413&view=rev Log: [CodeGen] Add initial support for union members in TBAA The basic idea behind this patch is that since in strict aliasing mode all accesses to union members require their outermost enclosing union objects to be specified explicitly, then for a couple given accesses to union members of the form p->a.b.c... q->x.y.z... it is known they can only alias if both p and q point to the same union type and offset ranges of members a.b.c... and x.y.z... overlap. Note that the actual types of the members do not matter. Specifically, in this patch we do the following: * Make unions to be valid TBAA base access types. This enables generation of TBAA type descriptors for unions. * Encode union types as structures with a single member of a special "union member" type. Currently we do not encode information about sizes of types, but conceptually such union members are considered to be of the size of the whole union. * Encode accesses to direct and indirect union members, including member arrays, as accesses to these special members. All accesses to members of a union thus get the same offset, which is the offset of the union they are part of. This means the existing LLVM TBAA machinery is able to handle such accesses with no changes. While this is already an improvement comparing to the current situation, that is, representing all union accesses as may-alias ones, there are further changes planned to complete the support for unions. One of them is storing information about access sizes so we can distinct accesses to non-overlapping union members, including accesses to different elements of member arrays. Another change is encoding type sizes in order to make it possible to compute offsets within constant-indexed array elements. These enhancements will be addressed with separate patches. Differential Revision: https://reviews.llvm.org/D39455 Added: cfe/trunk/test/CodeGen/tbaa-union.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h cfe/trunk/test/CodeGen/union-tbaa1.c Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=319413&r1=319412&r2=319413&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Nov 30 01:26:39 2017 @@ -3723,9 +3723,6 @@ LValue CodeGenFunction::EmitLValueForFie if (base.getTBAAInfo().isMayAlias() || rec->hasAttr() || FieldType->isVectorType()) { FieldTBAAInfo = TBAAAccessInfo::getMayAliasInfo(); - } else if (rec->isUnion()) { -// TODO: Support TBAA for unions. -FieldTBAAInfo = TBAAAccessInfo::getMayAliasInfo(); } else { // If no base type been assigned for the base access, then try to generate // one for this base lvalue. @@ -3736,16 +3733,26 @@ LValue CodeGenFunction::EmitLValueForFie "Nonzero offset for an access with no base type!"); } -// Adjust offset to be relative to the base type. -const ASTRecordLayout &Layout = -getContext().getASTRecordLayout(field->getParent()); -unsigned CharWidth = getContext().getCharWidth(); -if (FieldTBAAInfo.BaseType) - FieldTBAAInfo.Offset += - Layout.getFieldOffset(field->getFieldIndex()) / CharWidth; +// All union members are encoded to be of the same special type. +if (FieldTBAAInfo.BaseType && rec->isUnion()) + FieldTBAAInfo = TBAAAccessInfo::getUnionMemberInfo(FieldTBAAInfo.BaseType, + FieldTBAAInfo.Offset, + FieldTBAAInfo.Size); + +// For now we describe accesses to direct and indirect union members as if +// they were at the offset of their outermost enclosing union. +if (!FieldTBAAInfo.isUnionMember()) { + // Adjust offset to be relative to the base type. + const ASTRecordLayout &Layout = + getContext().getASTRecordLayout(field->getParent()); + unsigned CharWidth = getContext().getCharWidth(); + if (FieldTBAAInfo.BaseType) +FieldTBAAInfo.Offset += +Layout.getFieldOffset(field->getFieldIndex()) / CharWidth; -// Update the final access type. -FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType); + // Update the final access type. + FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType); +} } Address addr = base.getAddress(); Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=319413&r1=319412&r2=319413&view=diff =
r329814 - [NEON] Support vfma_n and vfms_n intrinsics
Author: kosarev Date: Wed Apr 11 07:43:11 2018 New Revision: 329814 URL: http://llvm.org/viewvc/llvm-project?rev=329814&view=rev Log: [NEON] Support vfma_n and vfms_n intrinsics Differential Revision: https://reviews.llvm.org/D45483 Modified: cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/test/CodeGen/aarch64-neon-2velem.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=329814&r1=329813&r2=329814&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Wed Apr 11 07:43:11 2018 @@ -621,8 +621,8 @@ def FMLS : SOpInst<"vfms", "", "dQd" // MUL, MLA, MLS, FMA, FMS definitions with scalar argument def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>; -def FMLA_N : SOpInst<"vfma_n", "ddds", "fQfQd", OP_FMLA_N>; -def FMLS_N : SOpInst<"vfms_n", "ddds", "fQfQd", OP_FMLS_N>; +def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>; +def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>; def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>; def MLS_N : SOpInst<"vmls_n", "ddds", "Qd", OP_MLS_N>; Modified: cfe/trunk/test/CodeGen/aarch64-neon-2velem.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-2velem.c?rev=329814&r1=329813&r2=329814&view=diff == --- cfe/trunk/test/CodeGen/aarch64-neon-2velem.c (original) +++ cfe/trunk/test/CodeGen/aarch64-neon-2velem.c Wed Apr 11 07:43:11 2018 @@ -3083,6 +3083,17 @@ float32x2_t test_vfma_n_f32(float32x2_t return vfma_n_f32(a, b, n); } +// CHECK-LABEL: @test_vfma_n_f64( +// CHECK: [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, i32 0 +// CHECK: [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8> +// CHECK: [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8> +// CHECK: [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8> +// CHECK: [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, <1 x double> [[VECINIT_I]], <1 x double> %a) +// CHECK: ret <1 x double> [[TMP3]] +float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) { + return vfma_n_f64(a, b, n); +} + // CHECK-LABEL: @test_vfmaq_n_f32( // CHECK: [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0 // CHECK: [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], float %n, i32 1 @@ -3110,6 +3121,18 @@ float32x2_t test_vfms_n_f32(float32x2_t return vfms_n_f32(a, b, n); } +// CHECK-LABEL: @test_vfms_n_f64( +// CHECK: [[SUB_I:%.*]] = fsub <1 x double> , %b +// CHECK: [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, i32 0 +// CHECK: [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8> +// CHECK: [[TMP1:%.*]] = bitcast <1 x double> [[SUB_I]] to <8 x i8> +// CHECK: [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8> +// CHECK: [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> [[SUB_I]], <1 x double> [[VECINIT_I]], <1 x double> %a) +// CHECK: ret <1 x double> [[TMP3]] +float64x1_t test_vfms_n_f64(float64x1_t a, float64x1_t b, float64_t n) { + return vfms_n_f64(a, b, n); +} + // CHECK-LABEL: @test_vfmsq_n_f32( // CHECK: [[SUB_I:%.*]] = fsub <4 x float> , %b // CHECK: [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r316896 - [CodeGen] Generate TBAA info for reference loads
Author: kosarev Date: Mon Oct 30 04:49:31 2017 New Revision: 316896 URL: http://llvm.org/viewvc/llvm-project?rev=316896&view=rev Log: [CodeGen] Generate TBAA info for reference loads Differential Revision: https://reviews.llvm.org/D39177 Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/test/CodeGen/tbaa-reference.cpp Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=316896&r1=316895&r2=316896&view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon Oct 30 04:49:31 2017 @@ -1189,8 +1189,8 @@ Address CodeGenFunction::GetAddrOfBlockD variable->getName()); } - if (auto refType = capture.fieldType()->getAs()) -addr = EmitLoadOfReference(addr, refType); + if (capture.fieldType()->isReferenceType()) +addr = EmitLoadOfReference(MakeAddrLValue(addr, capture.fieldType())); return addr; } Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=316896&r1=316895&r2=316896&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 30 04:49:31 2017 @@ -2160,22 +2160,30 @@ static LValue EmitThreadPrivateVarDeclLV return CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl); } -Address CodeGenFunction::EmitLoadOfReference(Address Addr, - const ReferenceType *RefTy, - LValueBaseInfo *BaseInfo, - TBAAAccessInfo *TBAAInfo) { - llvm::Value *Ptr = Builder.CreateLoad(Addr); - return Address(Ptr, getNaturalTypeAlignment(RefTy->getPointeeType(), - BaseInfo, TBAAInfo, - /* forPointeeType= */ true)); -} - -LValue CodeGenFunction::EmitLoadOfReferenceLValue(Address RefAddr, - const ReferenceType *RefTy) { - LValueBaseInfo BaseInfo; - TBAAAccessInfo TBAAInfo; - Address Addr = EmitLoadOfReference(RefAddr, RefTy, &BaseInfo, &TBAAInfo); - return MakeAddrLValue(Addr, RefTy->getPointeeType(), BaseInfo, TBAAInfo); +Address +CodeGenFunction::EmitLoadOfReference(LValue RefLVal, + LValueBaseInfo *PointeeBaseInfo, + TBAAAccessInfo *PointeeTBAAInfo) { + llvm::LoadInst *Load = Builder.CreateLoad(RefLVal.getAddress(), +RefLVal.isVolatile()); + TBAAAccessInfo RefTBAAInfo = RefLVal.getTBAAInfo(); + if (RefLVal.getBaseInfo().getMayAlias()) +RefTBAAInfo = CGM.getTBAAMayAliasAccessInfo(); + CGM.DecorateInstructionWithTBAA(Load, RefTBAAInfo); + + CharUnits Align = getNaturalTypeAlignment(RefLVal.getType()->getPointeeType(), +PointeeBaseInfo, PointeeTBAAInfo, +/* forPointeeType= */ true); + return Address(Load, Align); +} + +LValue CodeGenFunction::EmitLoadOfReferenceLValue(LValue RefLVal) { + LValueBaseInfo PointeeBaseInfo; + TBAAAccessInfo PointeeTBAAInfo; + Address PointeeAddr = EmitLoadOfReference(RefLVal, &PointeeBaseInfo, +&PointeeTBAAInfo); + return MakeAddrLValue(PointeeAddr, RefLVal.getType()->getPointeeType(), +PointeeBaseInfo, PointeeTBAAInfo); } Address CodeGenFunction::EmitLoadOfPointer(Address Ptr, @@ -2210,17 +2218,15 @@ static LValue EmitGlobalVarDeclLValue(Co V = EmitBitCastOfLValueToProperType(CGF, V, RealVarTy); CharUnits Alignment = CGF.getContext().getDeclAlign(VD); Address Addr(V, Alignment); - LValue LV; // Emit reference to the private copy of the variable if it is an OpenMP // threadprivate variable. if (CGF.getLangOpts().OpenMP && VD->hasAttr()) return EmitThreadPrivateVarDeclLValue(CGF, VD, T, Addr, RealVarTy, E->getExprLoc()); - if (auto RefTy = VD->getType()->getAs()) { -LV = CGF.EmitLoadOfReferenceLValue(Addr, RefTy); - } else { -LV = CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl); - } + LValue LV = VD->getType()->isReferenceType() ? + CGF.EmitLoadOfReferenceLValue(Addr, VD->getType(), +AlignmentSource::Decl) : + CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl); setObjCGCLValueClass(CGF.getContext(), E, LV); return LV; } @@ -2338,8 +2344,9 @@ LValue CodeGenFunction::EmitDeclRefLValu else if (CapturedSt
r316988 - [CodeGen] Propagate may-alias'ness of lvalues with TBAA info
Author: kosarev Date: Tue Oct 31 04:05:34 2017 New Revision: 316988 URL: http://llvm.org/viewvc/llvm-project?rev=316988&view=rev Log: [CodeGen] Propagate may-alias'ness of lvalues with TBAA info This patch fixes various places in clang to propagate may-alias TBAA access descriptors during construction of lvalues, thus eliminating the need for the LValueBaseInfo::MayAlias flag. This is part of D38126 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D39008 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGValue.h cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=316988&r1=316987&r2=316988&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Oct 31 04:05:34 2017 @@ -1538,8 +1538,6 @@ llvm::Value *CodeGenFunction::EmitLoadOf Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node); } - if (BaseInfo.getMayAlias()) -TBAAInfo = CGM.getTBAAMayAliasAccessInfo(); CGM.DecorateInstructionWithTBAA(Load, TBAAInfo); if (EmitScalarRangeCheck(Load, Ty, Loc)) { @@ -1622,8 +1620,6 @@ void CodeGenFunction::EmitStoreOfScalar( Store->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node); } - if (BaseInfo.getMayAlias()) -TBAAInfo = CGM.getTBAAMayAliasAccessInfo(); CGM.DecorateInstructionWithTBAA(Store, TBAAInfo); } @@ -2170,10 +2166,7 @@ CodeGenFunction::EmitLoadOfReference(LVa TBAAAccessInfo *PointeeTBAAInfo) { llvm::LoadInst *Load = Builder.CreateLoad(RefLVal.getAddress(), RefLVal.isVolatile()); - TBAAAccessInfo RefTBAAInfo = RefLVal.getTBAAInfo(); - if (RefLVal.getBaseInfo().getMayAlias()) -RefTBAAInfo = CGM.getTBAAMayAliasAccessInfo(); - CGM.DecorateInstructionWithTBAA(Load, RefTBAAInfo); + CGM.DecorateInstructionWithTBAA(Load, RefLVal.getTBAAInfo()); CharUnits Align = getNaturalTypeAlignment(RefLVal.getType()->getPointeeType(), PointeeBaseInfo, PointeeTBAAInfo, @@ -2356,11 +2349,10 @@ LValue CodeGenFunction::EmitDeclRefLValu LValue CapLVal = EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD), CapturedStmtInfo->getContextValue()); -bool MayAlias = CapLVal.getBaseInfo().getMayAlias(); return MakeAddrLValue( Address(CapLVal.getPointer(), getContext().getDeclAlign(VD)), -CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl, MayAlias), -CGM.getTBAAAccessInfo(CapLVal.getType())); +CapLVal.getType(), LValueBaseInfo(AlignmentSource::Decl), +CapLVal.getTBAAInfo()); } assert(isa(CurCodeDecl)); @@ -2504,7 +2496,7 @@ LValue CodeGenFunction::EmitUnaryOpLValu ? emitAddrOfRealComponent(LV.getAddress(), LV.getType()) : emitAddrOfImagComponent(LV.getAddress(), LV.getType())); LValue ElemLV = MakeAddrLValue(Component, T, LV.getBaseInfo(), - CGM.getTBAAAccessInfo(T)); + CGM.getTBAAInfoForSubobject(LV, T)); ElemLV.getQuals().addQualifiers(LV.getQuals()); return ElemLV; } @@ -3242,18 +3234,18 @@ LValue CodeGenFunction::EmitArraySubscri Addr = emitArraySubscriptGEP(*this, Addr, Idx, EltType, /*inbounds*/ true, SignedIndices, E->getExprLoc()); return MakeAddrLValue(Addr, EltType, LV.getBaseInfo(), - CGM.getTBAAAccessInfo(EltType)); + CGM.getTBAAInfoForSubobject(LV, EltType)); } - LValueBaseInfo BaseInfo; - TBAAAccessInfo TBAAInfo; + LValueBaseInfo EltBaseInfo; + TBAAAccessInfo EltTBAAInfo; Address Addr = Address::invalid(); if (const VariableArrayType *vla = getContext().getAsVariableArrayType(E->getType())) { // The base must be a pointer, which is not an aggregate. Emit // it. It needs to be emitted first in case it's what captures // the VLA bounds. -Addr = EmitPointerWithAlignment(E->getBase(), &BaseInfo, &TBAAInfo); +Addr = EmitPointerWithAlignment(E->getBase(), &EltBaseInfo, &EltTBAAInfo); auto *Idx = EmitIdxAfterBase(/*Promote*/true); // The element count here is the total number of non-VLA elements. @@ -3277,7 +3269,7 @@ LValue CodeGenFunction::EmitArraySubscri // Indexing over an interface, as
r318644 - [Driver] Add a cc1 flag for the new TBAA metadata format
Author: kosarev Date: Mon Nov 20 03:16:16 2017 New Revision: 318644 URL: http://llvm.org/viewvc/llvm-project?rev=318644&view=rev Log: [Driver] Add a cc1 flag for the new TBAA metadata format This patch starts a series of changes to add support for the new TBAA metadata format proposed in this llvm-dev thread: http://lists.llvm.org/pipermail/llvm-dev/2017-November/118748.html Differential Revision: https://reviews.llvm.org/D39955 Modified: cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=318644&r1=318643&r2=318644&view=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Nov 20 03:16:16 2017 @@ -244,6 +244,8 @@ def relaxed_aliasing : Flag<["-"], "rela HelpText<"Turn off Type Based Alias Analysis">; def no_struct_path_tbaa : Flag<["-"], "no-struct-path-tbaa">, HelpText<"Turn off struct-path aware Type Based Alias Analysis">; +def new_struct_path_tbaa : Flag<["-"], "new-struct-path-tbaa">, + HelpText<"Enable enhanced struct-path aware Type Based Alias Analysis">; def masm_verbose : Flag<["-"], "masm-verbose">, HelpText<"Generate verbose assembly output">; def mcode_model : Separate<["-"], "mcode-model">, Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=318644&r1=318643&r2=318644&view=diff == --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Nov 20 03:16:16 2017 @@ -144,6 +144,7 @@ ENUM_CODEGENOPT(StructReturnConvention, CODEGENOPT(RelaxAll , 1, 0) ///< Relax all machine code instructions. CODEGENOPT(RelaxedAliasing , 1, 0) ///< Set when -fno-strict-aliasing is enabled. CODEGENOPT(StructPathTBAA, 1, 0) ///< Whether or not to use struct-path TBAA. +CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced struct-path TBAA. CODEGENOPT(SaveTempLabels, 1, 0) ///< Save temporary labels. CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope detection ///< in AddressSanitizer Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=318644&r1=318643&r2=318644&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Nov 20 03:16:16 2017 @@ -546,6 +546,8 @@ static bool ParseCodeGenArgs(CodeGenOpti OPT_fuse_register_sized_bitfield_access); Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing); Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa); + Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) && + Args.hasArg(OPT_new_struct_path_tbaa); Opts.FineGrainedBitfieldAccesses = Args.hasFlag(OPT_ffine_grained_bitfield_accesses, OPT_fno_fine_grained_bitfield_accesses, false); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r318752 - [CodeGen] Generate TBAA type descriptors in a more reliable manner
Author: kosarev Date: Tue Nov 21 03:18:06 2017 New Revision: 318752 URL: http://llvm.org/viewvc/llvm-project?rev=318752&view=rev Log: [CodeGen] Generate TBAA type descriptors in a more reliable manner This patch introduces a couple of helper functions that make it possible to handle the caching logic in a single place. Differential Revision: https://reviews.llvm.org/D39953 Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=318752&r1=318751&r2=318752&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Tue Nov 21 03:18:06 2017 @@ -107,29 +107,7 @@ static bool isValidBaseType(QualType QTy return false; } -llvm::MDNode *CodeGenTBAA::getTypeInfo(QualType QTy) { - // At -O0 or relaxed aliasing, TBAA is not emitted for regular types. - if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing) -return nullptr; - - // If the type has the may_alias attribute (even on a typedef), it is - // effectively in the general char alias class. - if (TypeHasMayAlias(QTy)) -return getChar(); - - // We need this function to not fall back to returning the "omnipotent char" - // type node for aggregate and union types. Otherwise, any dereference of an - // aggregate will result into the may-alias access descriptor, meaning all - // subsequent accesses to direct and indirect members of that aggregate will - // be considered may-alias too. - // TODO: Combine getTypeInfo() and getBaseTypeInfo() into a single function. - if (isValidBaseType(QTy)) -return getBaseTypeInfo(QTy); - - const Type *Ty = Context.getCanonicalType(QTy).getTypePtr(); - if (llvm::MDNode *N = MetadataCache[Ty]) -return N; - +llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { // Handle builtin types. if (const BuiltinType *BTy = dyn_cast(Ty)) { switch (BTy->getKind()) { @@ -160,8 +138,7 @@ llvm::MDNode *CodeGenTBAA::getTypeInfo(Q // treating wchar_t, char16_t, and char32_t as distinct from their // "underlying types". default: - return MetadataCache[Ty] = -createTBAAScalarType(BTy->getName(Features), getChar()); + return createTBAAScalarType(BTy->getName(Features), getChar()); } } @@ -169,14 +146,13 @@ llvm::MDNode *CodeGenTBAA::getTypeInfo(Q // an object through a glvalue of other than one of the following types the // behavior is undefined: [...] a char, unsigned char, or std::byte type." if (Ty->isStdByteType()) -return MetadataCache[Ty] = getChar(); +return getChar(); // Handle pointers and references. // TODO: Implement C++'s type "similarity" and consider dis-"similar" // pointers distinct. if (Ty->isPointerType() || Ty->isReferenceType()) -return MetadataCache[Ty] = createTBAAScalarType("any pointer", -getChar()); +return createTBAAScalarType("any pointer", getChar()); // Enum types are distinct types. In C++ they have "underlying types", // however they aren't related for TBAA. @@ -186,16 +162,46 @@ llvm::MDNode *CodeGenTBAA::getTypeInfo(Q // TODO: Is there a way to get a program-wide unique name for a // decl with local linkage or no linkage? if (!Features.CPlusPlus || !ETy->getDecl()->isExternallyVisible()) - return MetadataCache[Ty] = getChar(); + return getChar(); SmallString<256> OutName; llvm::raw_svector_ostream Out(OutName); MContext.mangleTypeName(QualType(ETy, 0), Out); -return MetadataCache[Ty] = createTBAAScalarType(OutName, getChar()); +return createTBAAScalarType(OutName, getChar()); } // For now, handle any other kind of type conservatively. - return MetadataCache[Ty] = getChar(); + return getChar(); +} + +llvm::MDNode *CodeGenTBAA::getTypeInfo(QualType QTy) { + // At -O0 or relaxed aliasing, TBAA is not emitted for regular types. + if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing) +return nullptr; + + // If the type has the may_alias attribute (even on a typedef), it is + // effectively in the general char alias class. + if (TypeHasMayAlias(QTy)) +return getChar(); + + // We need this function to not fall back to returning the "omnipotent char" + // type node for aggregate and union types. Otherwise, any dereference of an + // aggregate will result into the may-alias access descriptor, meaning all + // subsequent accesses to direct and indirect members of that aggregate will + // be considered may-alias too. + // TODO: Combine getTypeInfo() and getBaseTypeInfo() into a single function. + if (isValidBaseType(QTy)) +return getBaseTypeInfo(QTy); + + const Type *Ty = Context.getCanonicalType(QTy).getTypePtr(); + if (llvm::MDNo
r323421 - [CodeGen] Decorate aggregate accesses with TBAA tags
Author: kosarev Date: Thu Jan 25 06:21:55 2018 New Revision: 323421 URL: http://llvm.org/viewvc/llvm-project?rev=323421&view=rev Log: [CodeGen] Decorate aggregate accesses with TBAA tags Differential Revision: https://reviews.llvm.org/D41539 Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprCXX.cpp cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp cfe/trunk/lib/CodeGen/CodeGenTBAA.h cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/test/CodeGen/tbaa-struct.cpp Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=323421&r1=323420&r2=323421&view=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Thu Jan 25 06:21:55 2018 @@ -1508,11 +1508,12 @@ void AtomicInfo::emitCopyIntoMemory(RVal // which means that the caller is responsible for having zeroed // any padding. Just do an aggregate copy of that type. if (rvalue.isAggregate()) { -CGF.EmitAggregateCopy(getAtomicAddress(), - rvalue.getAggregateAddress(), - getAtomicType(), - (rvalue.isVolatileQualified() - || LVal.isVolatileQualified())); +LValue Dest = CGF.MakeAddrLValue(getAtomicAddress(), getAtomicType()); +LValue Src = CGF.MakeAddrLValue(rvalue.getAggregateAddress(), +getAtomicType()); +bool IsVolatile = rvalue.isVolatileQualified() || + LVal.isVolatileQualified(); +CGF.EmitAggregateCopy(Dest, Src, getAtomicType(), IsVolatile); return; } Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=323421&r1=323420&r2=323421&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Jan 25 06:21:55 2018 @@ -3544,9 +3544,9 @@ void CodeGenFunction::EmitCallArg(CallAr } else { // We can't represent a misaligned lvalue in the CallArgList, so copy // to an aligned temporary now. - Address tmp = CreateMemTemp(type); - EmitAggregateCopy(tmp, L.getAddress(), type, L.isVolatile()); - args.add(RValue::getAggregate(tmp), type); + LValue Dest = MakeAddrLValue(CreateMemTemp(type), type); + EmitAggregateCopy(Dest, L, type, L.isVolatile()); + args.add(RValue::getAggregate(Dest.getAddress()), type); } return; } @@ -3884,7 +3884,9 @@ RValue CodeGenFunction::EmitCall(const C Address AI = CreateMemTemp(I->Ty, ArgInfo.getIndirectAlign(), "byval-temp", false); IRCallArgs[FirstIRArg] = AI.getPointer(); - EmitAggregateCopy(AI, Addr, I->Ty, RV.isVolatileQualified()); + LValue Dest = MakeAddrLValue(AI, I->Ty); + LValue Src = MakeAddrLValue(Addr, I->Ty); + EmitAggregateCopy(Dest, Src, I->Ty, RV.isVolatileQualified()); } else { // Skip the extra memcpy call. IRCallArgs[FirstIRArg] = Addr.getPointer(); Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=323421&r1=323420&r2=323421&view=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Jan 25 06:21:55 2018 @@ -640,8 +640,7 @@ static void EmitMemberInitializer(CodeGe LValue Src = CGF.EmitLValueForFieldInitialization(ThisRHSLV, Field); // Copy the aggregate. - CGF.EmitAggregateCopy(LHS.getAddress(), Src.getAddress(), FieldType, -LHS.isVolatileQualified()); + CGF.EmitAggregateCopy(LHS, Src, FieldType, LHS.isVolatileQualified()); // Ensure that we destroy the objects if an exception is thrown later in // the constructor. QualType::DestructionKind dtorKind = FieldType.isDestructedType(); @@ -2002,10 +2001,10 @@ void CodeGenFunction::EmitCXXConstructor assert(E->getNumArgs() == 1 && "unexpected argcount for trivial ctor"); const Expr *Arg = E->getArg(0); -QualType SrcTy = Arg->getType(); -Address Src = EmitLValue(Arg).getAddress(); +LValue Src = EmitLValue(Arg); QualType DestTy = getContext().getTypeDeclType(D->getParent()); -EmitAggregateCopyCtor(This, Sr