From: Ben Shi Date: Tue, 13 Dec 2022 04:07:40 +0000 (+0800) Subject: [clang] Do not extend i8 return values to i16 on AVR. X-Git-Tag: upstream/17.0.6~22984 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2638a7a34d97066caa234999055bf580cbab02f;p=platform%2Fupstream%2Fllvm.git [clang] Do not extend i8 return values to i16 on AVR. Reviewed By: Miss_Grape, aykevl Differential Revision: https://reviews.llvm.org/D139908 --- diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 98b54df..aec170a 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -8445,6 +8445,10 @@ public: LargeRet = true; return getNaturalAlignIndirect(Ty); } + // An i8 return value should not be extended to i16, since AVR has 8-bit + // registers. + if (Ty->isIntegralOrEnumerationType() && getContext().getTypeSize(Ty) <= 8) + return ABIArgInfo::getDirect(); // Otherwise we follow the default way which is compatible. return DefaultABIInfo::classifyReturnType(Ty); } diff --git a/clang/test/CodeGen/avr/avr-builtins.c b/clang/test/CodeGen/avr/avr-builtins.c index bdecff3f..7c2c424 100644 --- a/clang/test/CodeGen/avr/avr-builtins.c +++ b/clang/test/CodeGen/avr/avr-builtins.c @@ -8,7 +8,7 @@ unsigned char bitrev8(unsigned char data) { return __builtin_bitreverse8(data); } -// CHECK: define{{.*}} zeroext i8 @bitrev8 +// CHECK: define{{.*}} i8 @bitrev8 // CHECK: i8 @llvm.bitreverse.i8(i8 unsigned int bitrev16(unsigned int data) { @@ -35,7 +35,7 @@ unsigned char rotleft8(unsigned char x, unsigned char y) { return __builtin_rotateleft8(x, y); } -// CHECK: define{{.*}} zeroext i8 @rotleft8 +// CHECK: define{{.*}} i8 @rotleft8 // CHECK: i8 @llvm.fshl.i8(i8 unsigned int rotleft16(unsigned int x, unsigned int y) { @@ -62,7 +62,7 @@ unsigned char rotright8(unsigned char x, unsigned char y) { return __builtin_rotateright8(x, y); } -// CHECK: define{{.*}} zeroext i8 @rotright8 +// CHECK: define{{.*}} i8 @rotright8 // CHECK: i8 @llvm.fshr.i8(i8 unsigned int rotright16(unsigned int x, unsigned int y) {