================
@@ -371,17 +371,25 @@ ABIArgInfo SparcV9ABIInfo::classifyType(QualType Ty,
unsigned SizeLimit,
CoerceBuilder CB(VMContext, getDataLayout());
CB.addStruct(0, StrTy);
- // All structs, even empty ones, should take up a register argument slot,
- // so pin the minimum struct size to one bit.
- CB.pad(llvm::alignTo(
- std::max(CB.DL.getTypeSizeInBits(StrTy).getKnownMinValue(), uint64_t(1)),
- 64));
+
+ // All structs, even empty ones, should take up a register argument slot, so
+ // pin the minimum struct size to one bit. However, empty structs don't take
+ // up any stack slot, so only do it on register arguments (i.e. the first
+ // six).
+ bool IsStackArgument = RegOffset > 5;
+ uint64_t ActualSize = CB.DL.getTypeSizeInBits(StrTy).getKnownMinValue();
+ uint64_t ExpandedSize = std::max(ActualSize, uint64_t(1));
+ if (IsStackArgument)
+ ExpandedSize = ActualSize;
+
+ CB.pad(llvm::alignTo(ExpandedSize, 64));
RegOffset += PaddingSlots + CB.Size / 64;
// Try to use the original type for coercion.
llvm::Type *CoerceTy = CB.isUsableType(StrTy) ? StrTy : CB.getType();
- ABIArgInfo AAI = ABIArgInfo::getDirect(CoerceTy, 0, Padding);
+ ABIArgInfo AAI = ABIArgInfo::getDirect(CoerceTy, 0, Padding,
+ !IsStackArgument && ExpandedSize ==
0);
----------------
koachan wrote:
Tagging this as WIP since I'm not really sure if disabling flattening is the
correct way here.
My goal is to make sure that the argument size stays zero (so it doesn't take
up any stack slots) but doesn't get removed from the parameter list in the
generated IR (so that compiling functions like `unsigned long h(struct E a0,
struct E a1, struct E a2, struct E a3, struct E a4, struct E a5, struct E a6,
struct E a7, unsigned long u) { return u; }` doesn't crash clang)...
https://github.com/llvm/llvm-project/pull/217065
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits