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(
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.
// 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;
}
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
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);
// Other decoration.
if (IsVolatile)
store->setVolatile(true);
- if (dest.getTBAAInfo())
- CGM.DecorateInstructionWithTBAA(store, dest.getTBAAInfo());
+ if (dest.getTBAAAccessType())
+ CGM.DecorateInstructionWithTBAA(store, dest.getTBAAAccessType());
return;
}
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?
SourceLocation Loc) {
return EmitLoadOfScalar(lvalue.getAddress(), lvalue.isVolatile(),
lvalue.getType(), Loc, lvalue.getBaseInfo(),
- lvalue.getTBAAInfo(),
+ lvalue.getTBAAAccessType(),
lvalue.getTBAABaseType(), lvalue.getTBAAOffset(),
lvalue.isNontemporal());
}
QualType Ty,
SourceLocation Loc,
LValueBaseInfo BaseInfo,
- llvm::MDNode *TBAAInfo,
+ llvm::MDNode *TBAAAccessType,
QualType TBAABaseType,
uint64_t TBAAOffset,
bool isNontemporal) {
// 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();
}
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);
}
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) {
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);
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);
}
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
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);
}
// 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;
}
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;
// Initialize fields for TBAA.
this->TBAABaseType = Type;
this->TBAAOffset = 0;
- this->TBAAInfo = TBAAInfo;
+ this->TBAAAccessType = TBAAAccessType;
}
public:
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; }
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));
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;
}
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,
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);
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);
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
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() {
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.
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;
// 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
/* 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;
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(
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.