Index: cfe/trunk/lib/CodeGen/CGAtomic.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGAtomic.cpp +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp @@ -98,7 +98,7 @@ 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 @@ 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 @@ // 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 @@ 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 @@ 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 @@ // Other decoration. if (IsVolatile) store->setVolatile(true); - if (dest.getTBAAInfo()) - CGM.DecorateInstructionWithTBAA(store, dest.getTBAAInfo()); + if (dest.getTBAAAccessType()) + CGM.DecorateInstructionWithTBAA(store, dest.getTBAAAccessType()); return; } Index: cfe/trunk/lib/CodeGen/CGExpr.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGExpr.cpp +++ cfe/trunk/lib/CodeGen/CGExpr.cpp @@ -1165,7 +1165,7 @@ 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 @@ SourceLocation Loc) { return EmitLoadOfScalar(lvalue.getAddress(), lvalue.isVolatile(), lvalue.getType(), Loc, lvalue.getBaseInfo(), - lvalue.getTBAAInfo(), + lvalue.getTBAAAccessType(), lvalue.getTBAABaseType(), lvalue.getTBAAOffset(), lvalue.isNontemporal()); } @@ -1477,7 +1477,7 @@ QualType Ty, SourceLocation Loc, LValueBaseInfo BaseInfo, - llvm::MDNode *TBAAInfo, + llvm::MDNode *TBAAAccessType, QualType TBAABaseType, uint64_t TBAAOffset, bool isNontemporal) { @@ -1508,7 +1508,7 @@ // Atomic operations have to be done on integral types. LValue AtomicLValue = - LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo); + LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAAccessType); if (Ty->isAtomicType() || LValueIsSuitableForInlineAtomic(AtomicLValue)) { return EmitAtomicLoad(AtomicLValue, Loc).getScalarVal(); } @@ -1519,11 +1519,11 @@ Load->getContext(), llvm::ConstantAsMetadata::get(Builder.getInt32(1))); Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node); } - if (TBAAInfo) { + if (TBAAAccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias - ? CGM.getTBAAInfo(getContext().CharTy) - : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo, TBAAOffset); + ? CGM.getTBAATypeInfo(getContext().CharTy) + : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); if (TBAA) CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias); } @@ -1566,7 +1566,7 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, LValueBaseInfo BaseInfo, - llvm::MDNode *TBAAInfo, + llvm::MDNode *TBAAAccessType, bool isInit, QualType TBAABaseType, uint64_t TBAAOffset, bool isNontemporal) { @@ -1596,7 +1596,7 @@ Value = EmitToMemory(Value, Ty); LValue AtomicLValue = - LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo); + LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAAccessType); if (Ty->isAtomicType() || (!isInit && LValueIsSuitableForInlineAtomic(AtomicLValue))) { EmitAtomicStore(RValue::get(Value), AtomicLValue, isInit); @@ -1610,11 +1610,11 @@ llvm::ConstantAsMetadata::get(Builder.getInt32(1))); Store->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node); } - if (TBAAInfo) { + if (TBAAAccessType) { bool MayAlias = BaseInfo.getMayAlias(); llvm::MDNode *TBAA = MayAlias - ? CGM.getTBAAInfo(getContext().CharTy) - : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo, TBAAOffset); + ? CGM.getTBAATypeInfo(getContext().CharTy) + : CGM.getTBAAStructTagInfo(TBAABaseType, TBAAAccessType, TBAAOffset); if (TBAA) CGM.DecorateInstructionWithTBAA(Store, TBAA, MayAlias); } @@ -1624,8 +1624,9 @@ bool isInit) { EmitStoreOfScalar(value, lvalue.getAddress(), lvalue.isVolatile(), lvalue.getType(), lvalue.getBaseInfo(), - lvalue.getTBAAInfo(), isInit, lvalue.getTBAABaseType(), - lvalue.getTBAAOffset(), lvalue.isNontemporal()); + lvalue.getTBAAAccessType(), isInit, + lvalue.getTBAABaseType(), lvalue.getTBAAOffset(), + lvalue.isNontemporal()); } /// EmitLoadOfLValue - Given an expression that represents a value lvalue, this @@ -3725,9 +3726,9 @@ if (CGM.shouldUseTBAA()) { llvm::MDNode *tbaa; if (mayAlias) - tbaa = CGM.getTBAAInfo(getContext().CharTy); + tbaa = CGM.getTBAATypeInfo(getContext().CharTy); else - tbaa = CGM.getTBAAInfo(type); + tbaa = CGM.getTBAATypeInfo(type); if (tbaa) CGM.DecorateInstructionWithTBAA(load, tbaa); } @@ -3778,8 +3779,8 @@ // Fields of may_alias structs act like 'char' for TBAA purposes. // FIXME: this should get propagated down through anonymous structs // and unions. - if (mayAlias && LV.getTBAAInfo()) - LV.setTBAAInfo(CGM.getTBAAInfo(getContext().CharTy)); + if (mayAlias && LV.getTBAAAccessType()) + LV.setTBAAAccessType(CGM.getTBAATypeInfo(getContext().CharTy)); return LV; } Index: cfe/trunk/lib/CodeGen/CGValue.h =================================================================== --- cfe/trunk/lib/CodeGen/CGValue.h +++ cfe/trunk/lib/CodeGen/CGValue.h @@ -227,18 +227,19 @@ Expr *BaseIvarExp; - /// Used by struct-path-aware TBAA. + /// TBAABaseType - The base access type used by TBAA. QualType TBAABaseType; - /// Offset relative to the base type. + + /// TBAAOffset - Access offset used by TBAA. uint64_t TBAAOffset; - /// TBAAInfo - TBAA information to attach to dereferences of this LValue. - llvm::MDNode *TBAAInfo; + /// TBAAInfo - The final access type used by TBAA. + llvm::MDNode *TBAAAccessType; private: void Initialize(QualType Type, Qualifiers Quals, CharUnits Alignment, LValueBaseInfo BaseInfo, - llvm::MDNode *TBAAInfo = nullptr) { + llvm::MDNode *TBAAAccessType = nullptr) { assert((!Alignment.isZero() || Type->isIncompleteType()) && "initializing l-value with zero alignment!"); this->Type = Type; @@ -258,7 +259,7 @@ // Initialize fields for TBAA. this->TBAABaseType = Type; this->TBAAOffset = 0; - this->TBAAInfo = TBAAInfo; + this->TBAAAccessType = TBAAAccessType; } public: @@ -324,8 +325,8 @@ uint64_t getTBAAOffset() const { return TBAAOffset; } void setTBAAOffset(uint64_t O) { TBAAOffset = O; } - llvm::MDNode *getTBAAInfo() const { return TBAAInfo; } - void setTBAAInfo(llvm::MDNode *N) { TBAAInfo = N; } + llvm::MDNode *getTBAAAccessType() const { return TBAAAccessType; } + void setTBAAAccessType(llvm::MDNode *N) { TBAAAccessType = N; } const Qualifiers &getQuals() const { return Quals; } Qualifiers &getQuals() { return Quals; } @@ -386,7 +387,7 @@ static LValue MakeAddr(Address address, QualType type, ASTContext &Context, LValueBaseInfo BaseInfo, - llvm::MDNode *TBAAInfo = nullptr) { + llvm::MDNode *TBAAAccessType = nullptr) { Qualifiers qs = type.getQualifiers(); qs.setObjCGCAttr(Context.getObjCGCAttrKind(type)); @@ -394,7 +395,7 @@ R.LVType = Simple; assert(address.getPointer()->getType()->isPointerTy()); R.V = address.getPointer(); - R.Initialize(type, qs, address.getAlignment(), BaseInfo, TBAAInfo); + R.Initialize(type, qs, address.getAlignment(), BaseInfo, TBAAAccessType); return R; } Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h =================================================================== --- cfe/trunk/lib/CodeGen/CodeGenFunction.h +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h @@ -1910,14 +1910,14 @@ LValueBaseInfo BaseInfo = LValueBaseInfo(AlignmentSource::Type)) { return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, - CGM.getTBAAInfo(T)); + CGM.getTBAATypeInfo(T)); } LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment, LValueBaseInfo BaseInfo = LValueBaseInfo(AlignmentSource::Type)) { return LValue::MakeAddr(Address(V, Alignment), T, getContext(), - BaseInfo, CGM.getTBAAInfo(T)); + BaseInfo, CGM.getTBAATypeInfo(T)); } LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T); @@ -3050,7 +3050,7 @@ SourceLocation Loc, LValueBaseInfo BaseInfo = LValueBaseInfo(AlignmentSource::Type), - llvm::MDNode *TBAAInfo = nullptr, + llvm::MDNode *TBAAAccessType = nullptr, QualType TBAABaseTy = QualType(), uint64_t TBAAOffset = 0, bool isNontemporal = false); @@ -3068,8 +3068,8 @@ bool Volatile, QualType Ty, LValueBaseInfo BaseInfo = LValueBaseInfo(AlignmentSource::Type), - llvm::MDNode *TBAAInfo = nullptr, bool isInit = false, - QualType TBAABaseTy = QualType(), + llvm::MDNode *TBAAAccessType = nullptr, + bool isInit = false, QualType TBAABaseTy = QualType(), uint64_t TBAAOffset = 0, bool isNontemporal = false); /// EmitStoreOfScalar - Store a scalar value to an address, taking Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp @@ -171,7 +171,7 @@ LValueBaseInfo BaseInfo; CharUnits Alignment = getNaturalTypeAlignment(T, &BaseInfo); return LValue::MakeAddr(Address(V, Alignment), T, getContext(), BaseInfo, - CGM.getTBAAInfo(T)); + CGM.getTBAATypeInfo(T)); } /// Given a value of type T* that may not be to a complete object, Index: cfe/trunk/lib/CodeGen/CodeGenModule.h =================================================================== --- cfe/trunk/lib/CodeGen/CodeGenModule.h +++ cfe/trunk/lib/CodeGen/CodeGenModule.h @@ -652,7 +652,10 @@ CtorList &getGlobalCtors() { return GlobalCtors; } CtorList &getGlobalDtors() { return GlobalDtors; } - llvm::MDNode *getTBAAInfo(QualType QTy); + /// getTBAATypeInfo - Get metadata used to describe accesses to objects of + /// the given type. + llvm::MDNode *getTBAATypeInfo(QualType QTy); + llvm::MDNode *getTBAAInfoForVTablePtr(); llvm::MDNode *getTBAAStructInfo(QualType QTy); /// Return the path-aware tag for given base type, access node and offset. Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -573,10 +573,10 @@ Types.RefreshTypeCacheForClass(RD); } -llvm::MDNode *CodeGenModule::getTBAAInfo(QualType QTy) { +llvm::MDNode *CodeGenModule::getTBAATypeInfo(QualType QTy) { if (!TBAA) return nullptr; - return TBAA->getTBAAInfo(QTy); + return TBAA->getTypeInfo(QTy); } llvm::MDNode *CodeGenModule::getTBAAInfoForVTablePtr() { Index: cfe/trunk/lib/CodeGen/CodeGenTBAA.h =================================================================== --- cfe/trunk/lib/CodeGen/CodeGenTBAA.h +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.h @@ -95,9 +95,9 @@ MangleContext &MContext); ~CodeGenTBAA(); - /// getTBAAInfo - Get the TBAA MDNode to be used for a dereference - /// of the given type. - llvm::MDNode *getTBAAInfo(QualType QTy); + /// getTypeInfo - Get metadata used to describe accesses to objects of the + /// given type. + llvm::MDNode *getTypeInfo(QualType QTy); /// getTBAAInfoForVTablePtr - Get the TBAA MDNode to be used for a /// dereference of a vtable pointer. Index: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp @@ -88,8 +88,7 @@ return false; } -llvm::MDNode * -CodeGenTBAA::getTBAAInfo(QualType QTy) { +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; @@ -120,15 +119,15 @@ // Unsigned types can alias their corresponding signed types. case BuiltinType::UShort: - return getTBAAInfo(Context.ShortTy); + return getTypeInfo(Context.ShortTy); case BuiltinType::UInt: - return getTBAAInfo(Context.IntTy); + return getTypeInfo(Context.IntTy); case BuiltinType::ULong: - return getTBAAInfo(Context.LongTy); + return getTypeInfo(Context.LongTy); case BuiltinType::ULongLong: - return getTBAAInfo(Context.LongLongTy); + return getTypeInfo(Context.LongLongTy); case BuiltinType::UInt128: - return getTBAAInfo(Context.Int128Ty); + return getTypeInfo(Context.Int128Ty); // Treat all other builtin types as distinct types. This includes // treating wchar_t, char16_t, and char32_t as distinct from their @@ -212,7 +211,7 @@ /* Otherwise, treat whatever it is as a field. */ uint64_t Offset = BaseOffset; uint64_t Size = Context.getTypeSizeInChars(QTy).getQuantity(); - llvm::MDNode *TBAAInfo = MayAlias ? getChar() : getTBAAInfo(QTy); + llvm::MDNode *TBAAInfo = MayAlias ? getChar() : getTypeInfo(QTy); llvm::MDNode *TBAATag = getTBAAScalarTagInfo(TBAAInfo); Fields.push_back(llvm::MDBuilder::TBAAStructField(Offset, Size, TBAATag)); return true; @@ -268,7 +267,7 @@ if (isTBAAPathStruct(FieldQTy)) FieldNode = getTBAAStructTypeInfo(FieldQTy); else - FieldNode = getTBAAInfo(FieldQTy); + FieldNode = getTypeInfo(FieldQTy); if (!FieldNode) return StructTypeMetadataCache[Ty] = nullptr; Fields.push_back(std::make_pair(