[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)

Jonas Paulsson via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 5 00:28:09 PDT 2024


================
@@ -1185,6 +1189,9 @@ Currently, only the following parameter attributes are defined:
     value should be sign-extended to the extent required by the target's
     ABI (which is usually 32-bits) by the caller (for a parameter) or
     the callee (for a return value).
+``noext`` This indicates to the code generator that the parameter or return
+    value has the high bits undefined, as for a struct in register, and
+    therefore does not need to be sign or zero extended.
----------------
JonPsson1 wrote:

> Can we do IR verifier for ABI illegal cases instead?

In previous discussions it has been agreed to generally let the target decide on how to act on the argument extensions attributes. So we decided to keep the check for these in the (SystemZ) backend. Per my understanding, this is related to the target platform ABI - some targets like SystemZ has specific extension requirements of arguments. Others do not and can therefore ignore these attributes. Therefore, having a general IR verifier for this doesn't quite make sense - unless one would add a new hook as well to check with the target that it depends on valid argument extension attributes.

> My suggestion is to introduce ABI verification code for each target in the IR verifier...

I agree this would make sense, but think this could be a follow-up patch once we have the needed parts this patch provides.

> The goal is to get some sort of error from code like that, instead of an obscure miscompile.

Yes, if the front-end or an instrumentation pass forgets to add the extension, it could lead to wrong-code that is hard to track down. This is especially treacherous since somebody might work on a target that do not care about this at all and introduce a problem on another target that depends on it. In such a case it would be great if e.g. the SystemZ buildbot would fail by detecting the case with no extension attribute.



https://github.com/llvm/llvm-project/pull/100757


More information about the llvm-commits mailing list