diff --git a/clang/lib/CodeGen/Targets/AVR.cpp b/clang/lib/CodeGen/Targets/AVR.cpp index 26e2a22f14d1e..5399d12f7ce80 100644 --- a/clang/lib/CodeGen/Targets/AVR.cpp +++ b/clang/lib/CodeGen/Targets/AVR.cpp @@ -59,7 +59,7 @@ class AVRABIInfo : public DefaultABIInfo { unsigned TySize = getContext().getTypeSize(Ty); // An int8 type argument always costs two registers like an int16. - if (TySize == 8 && NumRegs >= 2) { + if (TySize == 8 && NumRegs >= 2 && Ty->isIntegralOrEnumerationType()) { NumRegs -= 2; return ABIArgInfo::getExtend(Ty); } diff --git a/clang/test/CodeGen/avr/argument.c b/clang/test/CodeGen/avr/argument.c index 31bf678c05a54..1776cd7cf2c01 100644 --- a/clang/test/CodeGen/avr/argument.c +++ b/clang/test/CodeGen/avr/argument.c @@ -114,3 +114,13 @@ struct s15 fooa(char a, char b) { x.arr[1] = b; return x; } + +struct s8_t { + char a; +}; + +// AVR: define {{.*}} i8 @foob(i8 {{.*}}) +// TINY: define {{.*}} i8 @foob(i8 {{.*}}) +char foob(struct s8_t a) { + return a.a + 1; +}