================
@@ -1059,6 +980,48 @@ void rewriteIndirectReturnCall(cir::CallOp call,
call->erase();
}
+/// Whether \p ty is an eightbyte that travels in a vector register. An x87
+/// long double is floating-point but travels in neither register class, so it
+/// is excluded. A caller reads a false result as the integer class.
+bool isSSERegisterClass(mlir::Type ty) {
+ if (mlir::isa<cir::VectorType>(ty))
+ return true;
+ if (auto fp = mlir::dyn_cast<cir::FPTypeInterface>(ty))
+ return &fp.getFloatSemantics() != &llvm::APFloat::x87DoubleExtended();
+ return false;
+}
+
+/// The boundary the caller aligned \p ty to in the argument area. An
+/// alignment attribute can raise a record above what its members imply, and
+/// only the record-layout metadata carries that, so the member-derived value
+/// alone can be too small.
+uint64_t argumentAreaAlign(mlir::Type ty, mlir::ModuleOp modOp,
+ const mlir::DataLayout &dl) {
+ uint64_t align = dl.getTypeABIAlignment(ty);
+ if (auto recTy = mlir::dyn_cast<cir::RecordType>(ty))
+ if (auto layout = cir::tryGetRecordLayout(modOp, recTy.getName()))
+ align = std::max<uint64_t>(align, layout.getRecordAlign());
----------------
adams381 wrote:
It can't. I tried putting the alignment on the record type so
`getTypeABIAlignment` could answer directly, and backed it out. Two cases
defeat it.
First, the attribute can sit on a field rather than on the record:
```c
struct S { __attribute__((aligned(32))) char c; char rest[31]; };
```
S is 32-aligned, but the field's type is still plain `char`. Neither S's type
nor any member's type records the 32.
Second, a member can be a record whose alignment vanishes when it lowers:
```c
union U { char buf[32]; } __attribute__((aligned(32)));
struct T { union U u; };
```
T is 32-aligned, but U lowers to a 32-byte array whose alignment is 1, so
reading the member's alignment gives 1.
The record layout holds the computed alignment in both cases, which is what
this reads. Neither shape had a test and both were fetching from an unrounded
cursor, so there are regression tests for them now.
https://github.com/llvm/llvm-project/pull/222420
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits