[PATCH] D133920: [X86][fastcall] Move capability check before free register update
Phoebe Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 15 00:54:03 PDT 2022
pengfei created this revision.
pengfei added a reviewer: rnk.
Herald added a project: All.
pengfei requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Fixes: #57737
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133920
Files:
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/mangle-windows.c
Index: clang/test/CodeGen/mangle-windows.c
===================================================================
--- clang/test/CodeGen/mangle-windows.c
+++ clang/test/CodeGen/mangle-windows.c
@@ -47,7 +47,7 @@
// X64: define dso_local void @f8(
void __fastcall f9(long long a, char b, char c, short d) {}
-// CHECK: define dso_local x86_fastcallcc void @"\01 at f9@20"(i64 noundef %a, i8 noundef signext %b, i8 noundef signext %c, i16 noundef signext %d)
+// CHECK: define dso_local x86_fastcallcc void @"\01 at f9@20"(i64 noundef %a, i8 inreg noundef signext %b, i8 inreg noundef signext %c, i16 noundef signext %d)
// X64: define dso_local void @f9(
void f12(void) {}
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1771,21 +1771,25 @@
}
bool X86_32ABIInfo::shouldPrimitiveUseInReg(QualType Ty, CCState &State) const {
- if (!updateFreeRegs(Ty, State))
+ auto CanUseInReg = [this](QualType Ty, CCState &State) {
+ if (State.CC == llvm::CallingConv::X86_FastCall ||
+ State.CC == llvm::CallingConv::X86_VectorCall ||
+ State.CC == llvm::CallingConv::X86_RegCall) {
+ if (getContext().getTypeSize(Ty) > 32)
+ return false;
+
+ return (Ty->isIntegralOrEnumerationType() || Ty->isPointerType() ||
+ Ty->isReferenceType());
+ }
+ return true;
+ };
+
+ if (!CanUseInReg(Ty, State) || !updateFreeRegs(Ty, State))
return false;
if (IsMCUABI)
return false;
- if (State.CC == llvm::CallingConv::X86_FastCall ||
- State.CC == llvm::CallingConv::X86_VectorCall ||
- State.CC == llvm::CallingConv::X86_RegCall) {
- if (getContext().getTypeSize(Ty) > 32)
- return false;
-
- return (Ty->isIntegralOrEnumerationType() || Ty->isPointerType() ||
- Ty->isReferenceType());
- }
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133920.460317.patch
Type: text/x-patch
Size: 1929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220915/c94207c5/attachment.bin>
More information about the cfe-commits
mailing list