================
@@ -37,8 +41,66 @@ bool TargetInfo::isPromotableInteger(const IntegerType *IT)
const {
return BitWidth < 32;
}
-ArgInfo TargetInfo::getNaturalAlignIndirect(const Type *Ty, bool ByVal) const {
- return ArgInfo::getIndirect(Ty->getAlignment(), ByVal);
+ArgInfo TargetInfo::getNaturalAlignIndirect(const Type *Ty, bool ByVal,
+ unsigned AddrSpace) const {
+ return ArgInfo::getIndirect(Ty->getAlignment(), ByVal, AddrSpace);
+}
+
+const Type *TargetInfo::isSingleElementStruct(const Type *Ty) const {
+ const auto *RT = dyn_cast<RecordType>(Ty);
+ if (!RT)
+ return nullptr;
+
+ if (RT->hasFlexibleArrayMember())
+ return nullptr;
+
+ const Type *Found = nullptr;
+
+ for (const FieldInfo &Base : RT->getBaseClasses()) {
+ const auto *BaseRT = dyn_cast<RecordType>(Base.FieldType);
+ if (!BaseRT || BaseRT->isEmpty())
+ continue;
+
+ if (Found)
+ return nullptr;
+
+ Found = isSingleElementStruct(Base.FieldType);
+ if (!Found)
+ return nullptr;
+ }
+
+ for (const FieldInfo &Field : RT->getFields()) {
+ if (Field.isEmpty())
+ continue;
+
+ if (Found)
+ return nullptr;
+
+ const Type *FieldTy = Field.FieldType;
+
+ // Treat single element arrays as the element.
+ while (const auto *AT = dyn_cast<ArrayType>(FieldTy)) {
+ if (AT->getNumElements() != 1)
+ break;
+ FieldTy = AT->getElementType();
+ }
+
+ if (!isAggregateTypeForABI(FieldTy)) {
+ Found = FieldTy;
+ } else {
+ Found = isSingleElementStruct(FieldTy);
+ if (!Found)
+ return nullptr;
+ }
+ }
+
+ // Padding beyond the element disqualifies the struct. Compare in-memory
+ // sizes, not raw bit widths, so an element with trailing padding of its own
+ // still matches the record wrapping it.
+ if (Found && Found->getTypeAllocSize() != Ty->getTypeAllocSize())
----------------
aobolensk wrote:
It is also gone for now
https://github.com/llvm/llvm-project/pull/223259
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits