================
@@ -2100,6 +2100,32 @@ TypeInfo ASTContext::getTypeInfo(const Type *T) const {
return TI;
}
+bool ASTContext::typeRequiresPreserveAlignUnderPragmaPack(QualType T) const {
+ T = T.getCanonicalType();
+ const llvm::Triple &Triple = Target->getTriple();
+ if (Triple.isOSWindows() && Triple.isWindowsMSVCEnvironment()) {
+ if (const auto *BT = T->getAs<BuiltinType>()) {
+ if (BT->getKind() == BuiltinType::LongDouble &&
+ &Target->getLongDoubleFormat() ==
&llvm::APFloat::x87DoubleExtended())
+ return true;
+ }
+ if (const auto *VT = T->getAs<VectorType>()) {
+ uint64_t VecWidth = getTypeSize(VT);
+ return VT->getVectorKind() == VectorKind::Generic &&
+ (VecWidth == 128 || VecWidth == 256) &&
+ VecWidth == getTypeAlign(VT);
+ }
+ }
+ if (const auto *AT = T->getAsArrayTypeUnsafe())
+ return typeRequiresPreserveAlignUnderPragmaPack(AT->getElementType());
+ if (const auto *RT = T->getAs<RecordType>()) {
+ for (const auto *Field : RT->getDecl()->fields())
+ if (typeRequiresPreserveAlignUnderPragmaPack(Field->getType()))
----------------
ojhunt wrote:
Or at least cache the query result
https://github.com/llvm/llvm-project/pull/208256
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits