[PATCH] D124435: [X86] Always extend the integer parameters in callee

Phoebe Wang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 26 05:16:19 PDT 2022


pengfei added inline comments.


================
Comment at: clang/lib/CodeGen/CGCall.cpp:2451
+      // attribute to the callee.
+      if (AttrOnCallSite || AI.getKind() == ABIArgInfo::Extend) {
+        if (AI.isSignExt())
----------------
LiuChen3 wrote:
> pengfei wrote:
> > Does the change affect Windows? Seems Win64 doesn't extend on caller. https://godbolt.org/z/c95hvvsWf
> No.  This patch didn't nothing for Win64 ABI.
But I found some Windows tests are affected?


================
Comment at: clang/test/CodeGen/X86/integer_argument_passing.c:2
+// RUN: %clang_cc1 -O2 -triple -x86_64-linux-gnu %s -emit-llvm -o - | FileCheck %s --check-prefixes=EXTEND,CHECK
+// RUN: %clang_cc1 -O2 -triple -i386-linux-gnu %s -emit-llvm -o - | FileCheck %s --check-prefixes=EXTEND,CHECK
+// RUN: %clang_cc1 -O2 -triple -i386-pc-win32 %s -emit-llvm -o - | FileCheck %s --check-prefixes=EXTEND,CHECK
----------------
LiuChen3 wrote:
> pengfei wrote:
> > Maybe we can remove the tests for i386 given it's only for 64 bits ABI?
> According to the meaning of `ConservativeExtend`, I think the 32bit ABI needs to be modified as well:
> https://godbolt.org/z/W1Ma1T3f3
> The dump of currently clang-cl:
> ```
> _square:
>         movb    4(%esp), %al
>         mulb    %al
>         mulb    8(%esp)
>         retl
> 
>         .def    _baz;
>         .scl    2;
>         .type   32;
>         .endef
>         .section        .text,"xr",one_only,_baz
>         .globl  _baz
>         .p2align        4, 0x90
> _baz:
>         movswl  4(%esp), %eax
>         pushl   %eax
>         calll   _bar
>         addl    $4, %esp
>         retl
> ```
> Of course with this patch the behavior of clang-cl is still different from cl.exe, but I think it fits the meaning of `ConservativeExtend`.
My point was, i386 is passing arguments by stack. The extensions don't make sense under the circumstances. That's what I understood the comments in above test 2007-06-18-SextAttrAggregate.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124435



More information about the cfe-commits mailing list