[clang] Fix incorrect register information for AVR (#193940)
This commit is contained in:
@@ -77,9 +77,10 @@ public:
|
||||
|
||||
ArrayRef<const char *> getGCCRegNames() const override {
|
||||
static const char *const GCCRegNames[] = {
|
||||
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
|
||||
"r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19",
|
||||
"r20", "r21", "r22", "r23", "r24", "r25", "X", "Y", "Z", "SP"};
|
||||
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8",
|
||||
"r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
|
||||
"r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
|
||||
"r27", "r28", "r29", "r30", "r31", "__SP_L__", "__SP_H__"};
|
||||
return llvm::ArrayRef(GCCRegNames);
|
||||
}
|
||||
|
||||
@@ -89,11 +90,8 @@ public:
|
||||
|
||||
ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override {
|
||||
static const TargetInfo::AddlRegName AddlRegNames[] = {
|
||||
{{"r26", "r27"}, 26},
|
||||
{{"r28", "r29"}, 27},
|
||||
{{"r30", "r31"}, 28},
|
||||
{{"SPL", "SPH"}, 29},
|
||||
};
|
||||
{{"xl", "X"}, 26}, {{"xh"}, 27}, {{"yl", "Y"}, 28},
|
||||
{{"yh"}, 29}, {{"zl", "Z"}, 30}, {{"zh"}, 31}};
|
||||
return llvm::ArrayRef(AddlRegNames);
|
||||
}
|
||||
|
||||
|
||||
17
clang/test/CodeGen/avr/issue-176830.c
Normal file
17
clang/test/CodeGen/avr/issue-176830.c
Normal file
@@ -0,0 +1,17 @@
|
||||
// RUN: %clang_cc1 -triple avr -target-cpu atmega328 -emit-llvm < %s | FileCheck %s
|
||||
|
||||
// This test case verifies https://github.com/llvm/llvm-project/issues/176830,
|
||||
// and the test code is gained from
|
||||
// https://github.com/avrdudes/avr-libc/blob/main/include/string.h
|
||||
|
||||
unsigned int strlen(const char *__s) {
|
||||
if (__builtin_constant_p (__builtin_strlen (__s))) {
|
||||
return __builtin_strlen (__s);
|
||||
} else {
|
||||
register const char *__r24 __asm("24") = __s;
|
||||
register unsigned int __res __asm("24");
|
||||
// CHECK: call addrspace(0) i16 asm "call ${2:x}", "={r24},{r24},i,~{r30},~{r31},~{memory}"(ptr %1, ptr addrspace(1) @strlen)
|
||||
__asm ("%~call %x2" : "=r" (__res) : "r" (__r24), "i" (strlen) : "30", "31", "memory");
|
||||
return __res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user