[clang] 597accf - [clang][CodeGen][AVR] Fix a crash in AVRABIInfo (#131976)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 21 22:22:36 PDT 2025
Author: Ben Shi
Date: 2025-03-22T13:22:32+08:00
New Revision: 597accfea6150e77304427fb97d0c3798178e040
URL: https://github.com/llvm/llvm-project/commit/597accfea6150e77304427fb97d0c3798178e040
DIFF: https://github.com/llvm/llvm-project/commit/597accfea6150e77304427fb97d0c3798178e040.diff
LOG: [clang][CodeGen][AVR] Fix a crash in AVRABIInfo (#131976)
fixes https://github.com/llvm/llvm-project/issues/131967
Added:
Modified:
clang/lib/CodeGen/Targets/AVR.cpp
clang/test/CodeGen/avr/argument.c
Removed:
################################################################################
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;
+}
More information about the cfe-commits
mailing list