[PATCH] D112413: [X86] Add -mskip-rax-setup support to align with GCC

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 27 14:52:21 PDT 2021


MaskRay added inline comments.


================
Comment at: clang/include/clang/Driver/Options.td:3193
+def mskip_rax_setup : Flag<["-"], "mskip-rax-setup">, Group<m_Group>, Flags<[NoXarchOption]>,
+  HelpText<"Skip setting up RAX register when passing variable arguments (x86 only)">;
 def mstackrealign : Flag<["-"], "mstackrealign">, Group<m_Group>, Flags<[CC1Option]>,
----------------
nickdesaulniers wrote:
> I think GCC support `-mno-skip-rax-setup` as well. Can you please add that (and tests for it) as well?  We don't need to actually handle it, I think, but we shouldn't warn about the flag being unsupported, for example.
Consider `SimpleMFlag`


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:96
 
+static cl::opt<bool> SkipRaxSetup(
+    "x86-skip-rax-setup", cl::init(false),
----------------
nickdesaulniers wrote:
> If it's a command line option rather than encoded in the IR, then this won't be handled correctly under LTO (we support building the x86 linux kernel under LTO), unless the linker re-passes the flag.  I've been trying to avoid that by encoding this information properly in IR rather than rely on codegen command line options which I find brittle.  Please see https://reviews.llvm.org/D103928 as an example.
This depends on how frequent the feature is used.

I see that `arch/x86/Makefile` may add `-mskip-rax-setup` which is presumably used by all C files, so a module flag metadata suffices. If there are mix-and-match cases for different modules (e.g. ssp/nossp) a function attribute may be used. If a feature is really obscure than I might not consider wasting an IR attribute on it. Arguably if a feature is sufficient obscure we may not want to port it from GCC at all.

So "This fixes pr23258." in the description should state the use case to give archaeologists a hint why the feature is added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112413



More information about the cfe-commits mailing list