[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 03:12:14 PDT 2022


pengfei added inline comments.


================
Comment at: clang/docs/ClangCommandLineReference.rst:2988-2992
+.. option:: -mconservative-extend
+Always extend the integer parameter both in the callee and caller.
+
+.. option:: -mno-conservative-extend
+Keep the original integer parameter passing behavior.
----------------
Combine like others?


================
Comment at: clang/include/clang/CodeGen/CGFunctionInfo.h:202-205
+    if (Ty->hasSignedIntegerRepresentation())
+      AI.setSignExt(true);
+    else
+      AI.setSignExt(false);
----------------
`AI.setSignExt(Ty->hasSignedIntegerRepresentation())` for short?
Or we can remove the else block since `SignExt` is initialized to `false`?


================
Comment at: clang/include/clang/CodeGen/CGFunctionInfo.h:333
   bool canHaveCoerceToType() const {
-    return isDirect() || isExtend() || isCoerceAndExpand();
+    return isDirect() || isExtend() || isCoerceAndExpand() ||
+           isConservativeExtend();
----------------
Can we move it to `isExtend`? e.g. `TheKind == Expand | TheKind == ConservativeExtend`


================
Comment at: clang/lib/CodeGen/CGCall.cpp:2451
+      // attribute to the callee.
+      if (AttrOnCallSite || AI.getKind() == ABIArgInfo::Extend) {
+        if (AI.isSignExt())
----------------
Does the change affect Windows? Seems Win64 doesn't extend on caller. https://godbolt.org/z/c95hvvsWf


================
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
----------------
Maybe we can remove the tests for i386 given it's only for 64 bits ABI?


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