Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang-repl] Assertion "Narrow integer argument must have a valid extension type." failed. #109658

Open
JonPsson1 opened this issue Sep 23, 2024 · 0 comments
Labels
backend:SystemZ crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@JonPsson1
Copy link
Contributor

With the recent strengthening of the handling of extensions of narrow integer arguments (commit 1412022), it is now possible to detect cases of missing argument extensions, although there are still some issues that keeps this disabled by default. Many tests under Interpreter/ fails, for example:

cat ~/llvm-project/clang/test/Interpreter/assigment-with-implicit-ctor.cpp | ~/llvm-project/build/bin/clang-repl
good
SystemZISelLowering.cpp:9861: void llvm::SystemZTargetLowering::verifyNarrowIntegerArgs(const llvm::SmallVectorImpl<llvm::ISD::OutputArg>&, bool) const: Assertion `(VT != MVT::i32 || (Flags.isSExt() || Flags.isZExt() || Flags.isNoExt())) && "Narrow integer argument must have a valid extension type."' failed.

What this means is that there is a narrow (<=32 bit) integer argument that is neither sign or zero extended, and is also not marked as noext, which should be done for "struct-in-reg". So this may or may not be a "bug" (missing sign/zero extension), or it could be an argument that should be marked as noext. See https://llvm.org/docs/LangRef.html#parameter-attributes.

Unfortunately I have not found a way to pass the CodeGen CL option via clang-repl to be able to reproduce this. I tried e.g.
cat ~/llvm-project/clang/test/Interpreter/assigment-with-implicit-ctor.cpp | ~/llvm-project/install/bin/clang-repl -Xcc -mllvm -Xcc -argext-abi-check

, but without any luck. So unless it is actually possible to pass that option through to the backend, it is needed to do this instead:

diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 3dabc5e..5119f66 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -9843,8 +9843,8 @@ verifyNarrowIntegerArgs(const SmallVectorImpl<ISD::OutputArg> &Outs,
 
   // Temporarily only do the check when explicitly requested, until it can be
   // enabled by default.
-  if (!EnableIntArgExtCheck)
-    return;
+  // if (!EnableIntArgExtCheck)
+  //   return;
 
   if (EnableIntArgExtCheck.getNumOccurrences()) {
     if (!EnableIntArgExtCheck)

This comments out the disabling of this check.

CCing some folks with the hope of help with this, thanks: @vgvassilev @hahnjo @vitalybuka @nico @weliveindetail @nikic

@EugeneZelenko EugeneZelenko added backend:SystemZ crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:SystemZ crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

2 participants