[PATCH] D139908: [clang] Do not extend i8 return values to i16 on AVR.

Ben Shi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 21 04:34:18 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb2638a7a34d9: [clang] Do not extend i8 return values to i16 on AVR. (authored by benshi001).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139908/new/

https://reviews.llvm.org/D139908

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/avr/avr-builtins.c


Index: clang/test/CodeGen/avr/avr-builtins.c
===================================================================
--- clang/test/CodeGen/avr/avr-builtins.c
+++ clang/test/CodeGen/avr/avr-builtins.c
@@ -8,7 +8,7 @@
     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 @@
     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 @@
     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) {
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8445,6 +8445,10 @@
       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);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139908.484533.patch
Type: text/x-patch
Size: 1518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221221/ea2942b9/attachment.bin>


More information about the cfe-commits mailing list