|
@@ -1174,8 +1174,7 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
|
|
llvm::Value *V = LV.getPointer();
|
|
llvm::Value *V = LV.getPointer();
|
|
Scope.ForceCleanup({&V});
|
|
Scope.ForceCleanup({&V});
|
|
return LValue::MakeAddr(Address(V, LV.getAlignment()), LV.getType(),
|
|
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
|
|
// FIXME: Is it possible to create an ExprWithCleanups that produces a
|
|
// bitfield lvalue or some other non-simple lvalue?
|
|
// bitfield lvalue or some other non-simple lvalue?
|
|
@@ -1514,7 +1513,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
|
|
|
|
|
|
// Atomic operations have to be done on integral types.
|
|
// Atomic operations have to be done on integral types.
|
|
LValue AtomicLValue =
|
|
LValue AtomicLValue =
|
|
- LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo.AccessType);
|
|
|
|
|
|
+ LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo);
|
|
if (Ty->isAtomicType() || LValueIsSuitableForInlineAtomic(AtomicLValue)) {
|
|
if (Ty->isAtomicType() || LValueIsSuitableForInlineAtomic(AtomicLValue)) {
|
|
return EmitAtomicLoad(AtomicLValue, Loc).getScalarVal();
|
|
return EmitAtomicLoad(AtomicLValue, Loc).getScalarVal();
|
|
}
|
|
}
|
|
@@ -1525,14 +1524,10 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
|
|
Load->getContext(), llvm::ConstantAsMetadata::get(Builder.getInt32(1)));
|
|
Load->getContext(), llvm::ConstantAsMetadata::get(Builder.getInt32(1)));
|
|
Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
|
|
Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
|
|
}
|
|
}
|
|
- if (TBAAInfo.AccessType) {
|
|
|
|
- bool MayAlias = BaseInfo.getMayAlias();
|
|
|
|
- llvm::MDNode *TBAA = MayAlias
|
|
|
|
- ? CGM.getTBAAMayAliasTypeInfo()
|
|
|
|
- : CGM.getTBAAStructTagInfo(TBAAInfo);
|
|
|
|
- if (TBAA)
|
|
|
|
- CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ if (BaseInfo.getMayAlias())
|
|
|
|
+ TBAAInfo = CGM.getTBAAMayAliasAccessInfo();
|
|
|
|
+ CGM.DecorateInstructionWithTBAA(Load, TBAAInfo);
|
|
|
|
|
|
if (EmitScalarRangeCheck(Load, Ty, Loc)) {
|
|
if (EmitScalarRangeCheck(Load, Ty, Loc)) {
|
|
// In order to prevent the optimizer from throwing away the check, don't
|
|
// In order to prevent the optimizer from throwing away the check, don't
|
|
@@ -1599,7 +1594,7 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr,
|
|
Value = EmitToMemory(Value, Ty);
|
|
Value = EmitToMemory(Value, Ty);
|
|
|
|
|
|
LValue AtomicLValue =
|
|
LValue AtomicLValue =
|
|
- LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo.AccessType);
|
|
|
|
|
|
+ LValue::MakeAddr(Addr, Ty, getContext(), BaseInfo, TBAAInfo);
|
|
if (Ty->isAtomicType() ||
|
|
if (Ty->isAtomicType() ||
|
|
(!isInit && LValueIsSuitableForInlineAtomic(AtomicLValue))) {
|
|
(!isInit && LValueIsSuitableForInlineAtomic(AtomicLValue))) {
|
|
EmitAtomicStore(RValue::get(Value), AtomicLValue, isInit);
|
|
EmitAtomicStore(RValue::get(Value), AtomicLValue, isInit);
|
|
@@ -1613,14 +1608,10 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr,
|
|
llvm::ConstantAsMetadata::get(Builder.getInt32(1)));
|
|
llvm::ConstantAsMetadata::get(Builder.getInt32(1)));
|
|
Store->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
|
|
Store->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
|
|
}
|
|
}
|
|
- if (TBAAInfo.AccessType) {
|
|
|
|
- bool MayAlias = BaseInfo.getMayAlias();
|
|
|
|
- llvm::MDNode *TBAA = MayAlias
|
|
|
|
- ? CGM.getTBAAMayAliasTypeInfo()
|
|
|
|
- : CGM.getTBAAStructTagInfo(TBAAInfo);
|
|
|
|
- if (TBAA)
|
|
|
|
- CGM.DecorateInstructionWithTBAA(Store, TBAA, MayAlias);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ if (BaseInfo.getMayAlias())
|
|
|
|
+ TBAAInfo = CGM.getTBAAMayAliasAccessInfo();
|
|
|
|
+ CGM.DecorateInstructionWithTBAA(Store, TBAAInfo);
|
|
}
|
|
}
|
|
|
|
|
|
void CodeGenFunction::EmitStoreOfScalar(llvm::Value *value, LValue lvalue,
|
|
void CodeGenFunction::EmitStoreOfScalar(llvm::Value *value, LValue lvalue,
|
|
@@ -3727,12 +3718,9 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
|
|
|
|
|
|
// Loading the reference will disable path-aware TBAA.
|
|
// Loading the reference will disable path-aware TBAA.
|
|
TBAAPath = false;
|
|
TBAAPath = false;
|
|
- if (CGM.shouldUseTBAA()) {
|
|
|
|
- llvm::MDNode *tbaa = mayAlias ? CGM.getTBAAMayAliasTypeInfo() :
|
|
|
|
- CGM.getTBAATypeInfo(type);
|
|
|
|
- if (tbaa)
|
|
|
|
- CGM.DecorateInstructionWithTBAA(load, tbaa);
|
|
|
|
- }
|
|
|
|
|
|
+ TBAAAccessInfo TBAAInfo = mayAlias ? CGM.getTBAAMayAliasAccessInfo() :
|
|
|
|
+ CGM.getTBAAAccessInfo(type);
|
|
|
|
+ CGM.DecorateInstructionWithTBAA(load, TBAAInfo);
|
|
|
|
|
|
mayAlias = false;
|
|
mayAlias = false;
|
|
type = refType->getPointeeType();
|
|
type = refType->getPointeeType();
|
|
@@ -3762,17 +3750,33 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
|
|
|
|
|
|
LValue LV = MakeAddrLValue(addr, type, FieldBaseInfo);
|
|
LValue LV = MakeAddrLValue(addr, type, FieldBaseInfo);
|
|
LV.getQuals().addCVRQualifiers(cvr);
|
|
LV.getQuals().addCVRQualifiers(cvr);
|
|
- if (TBAAPath) {
|
|
|
|
|
|
+
|
|
|
|
+ // 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.setTBAAInfo(CGM.getTBAAMayAliasAccessInfo());
|
|
|
|
+ } else if (TBAAPath) {
|
|
|
|
+ // If no base type been assigned for the base access, then try to generate
|
|
|
|
+ // one for this base lvalue.
|
|
|
|
+ TBAAAccessInfo TBAAInfo = base.getTBAAInfo();
|
|
|
|
+ if (!TBAAInfo.BaseType) {
|
|
|
|
+ TBAAInfo.BaseType = CGM.getTBAABaseTypeInfo(base.getType());
|
|
|
|
+ assert(!TBAAInfo.Offset &&
|
|
|
|
+ "Nonzero offset for an access with no base type!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Adjust offset to be relative to the base type.
|
|
const ASTRecordLayout &Layout =
|
|
const ASTRecordLayout &Layout =
|
|
getContext().getASTRecordLayout(field->getParent());
|
|
getContext().getASTRecordLayout(field->getParent());
|
|
- // Set the base type to be the base type of the base LValue and
|
|
|
|
- // update offset to be relative to the base type.
|
|
|
|
unsigned CharWidth = getContext().getCharWidth();
|
|
unsigned CharWidth = getContext().getCharWidth();
|
|
- TBAAAccessInfo TBAAInfo = mayAlias ?
|
|
|
|
- TBAAAccessInfo(CGM.getTBAAMayAliasTypeInfo()) :
|
|
|
|
- TBAAAccessInfo(base.getTBAAInfo().BaseType, CGM.getTBAATypeInfo(type),
|
|
|
|
- base.getTBAAInfo().Offset + Layout.getFieldOffset(
|
|
|
|
- field->getFieldIndex()) / CharWidth);
|
|
|
|
|
|
+ if (TBAAInfo.BaseType)
|
|
|
|
+ TBAAInfo.Offset +=
|
|
|
|
+ Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
|
|
|
|
+
|
|
|
|
+ // Update the final access type.
|
|
|
|
+ TBAAInfo.AccessType = LV.getTBAAInfo().AccessType;
|
|
|
|
+
|
|
LV.setTBAAInfo(TBAAInfo);
|
|
LV.setTBAAInfo(TBAAInfo);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3780,12 +3784,6 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
|
|
if (LV.getQuals().getObjCGCAttr() == Qualifiers::Weak)
|
|
if (LV.getQuals().getObjCGCAttr() == Qualifiers::Weak)
|
|
LV.getQuals().removeObjCGCAttr();
|
|
LV.getQuals().removeObjCGCAttr();
|
|
|
|
|
|
- // 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.getTBAAAccessType())
|
|
|
|
- LV.setTBAAAccessType(CGM.getTBAAMayAliasTypeInfo());
|
|
|
|
-
|
|
|
|
return LV;
|
|
return LV;
|
|
}
|
|
}
|
|
|
|
|