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

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 7 03:11:42 PDT 2022


lebedev.ri added a comment.

In D122963#3435629 <https://reviews.llvm.org/D122963#3435629>, @LiuChen3 wrote:

> In D122963#3435619 <https://reviews.llvm.org/D122963#3435619>, @lebedev.ri wrote:
>
>> Still not okay with it. The fix is to fix whatever is emitting the attribute, not completely ignore it.
>
> I don't quite understand what you mean. 
> If there is no such attribute, it should not do any extension itself. Regardless of whether this function is only a local linked. The optimization here is only for parameters with zeroext/signext  attributes.

If there is an `zeroext` attribute on the function argument, it tells us that the **caller** is responsible to ensure that the `i8` argument,
which is passed in an `i64` register, does not have garbage bits in the upper 64-8 bits, but those bits are zeros, so we don't need to zeroext ourselves.
If the caller forgets to do that, the behavior is undefined. If the attribute is present, but the caller wasn't actually supposed to zeroext (ABI mismatch),
then whoever has put that attribute there is at fault. Sometimes ignoring the attribute and performing zeroext ourselves is a workaround for ABI mismatch.


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