[PATCH] D122963: [X86] Extend the integer parameter if the function isn't local linked

John McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 18 21:40:01 PDT 2022


rjmccall added a comment.

>From Michael Matz's comments on the GCC bug and some of the linked conversation, it sounds pretty clear that the psABI does not require extension.  They could certainly be more explicit about that in the ABI, but they're under no real obligation to: the baseline assumption should always be that things not stated are not guaranteed, so if the psABI intended extension to be required, the document would really need to state it positively, rather than leaving it to be inferred.

Of course, that creates a problem, because clang is not following the psABI.  Platforms where clang is the system compiler have the option of declaring clang's current behavior to be their platform ABI and documenting the variance, if they like.  Otherwise, clang needs to come into compliance with the psABI, but of course it also has to maintain compatibility with code emitted by old versions of clang, which are extending in the caller and assuming extension in the callee.  As has been pointed out, those goals are not incompatible: we just need to conservatively extend in the caller and not assume extension in the callee.  That won't be free, but it seems like what we have to do in order to make up for years of miscompilation, at least by default.

That said, I agree with the people who say that it's not the backend's responsibility to make this policy choice.  The frontend should be emitting IR correctly to get the behavior it wants.  So if we accept that the frontend might legitimately want conservative extension, the immediate question is whether we actually have a way to request it.  I suspect that we don't, unless we've recently gotten much stricter about treating call-site and declaration attributes as independent.

So to recap:

1. We should add a way for frontends to request conservative extension.
2. clang should request conservative extension on most x86_64 platforms by default.
3. clang can add a flag to control the ABI it uses for clients that are unwilling to pay the cost of conservative extension.
4. Platforms that use clang as a system compiler should decide whether they want to (a) default to conservative extension or (b) document that they use caller extension and thus vary from the psABI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122963



More information about the llvm-commits mailing list