<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/109658>109658</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang-repl] Assertion "Narrow integer argument must have a valid extension type." failed.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          JonPsson1
      </td>
    </tr>
</table>

<pre>
    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 

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8Vl1v47rR_jX0zUCCTfnzwheJs36RF3t2iybdU5w7ShxLPKZIlRzZcS_624uhrDibTduDLlDAsCiRfOb7mVExmtohbsXiXiweJqqnxoft_3v3pxi9m01Kry_bXw01QA1CwAodQaSArqYGnXE1-EPaa5TT9vqOL4QuGu8ivzkVgj-DcYQ1BlCh7lt0FEHIdeXb1hDM5jM5lVLIjZA7MAQmgvNn6HyMprQI5EEjYUVQqYgJtjUxsrwR741UBlGWGt_XSfGAoAJCJGMtRN8imBh7jECNIjgidrw0EbSJqrSoobyAxoPqLeXwi3IXIIwUoXcaAzw6wtAFJAxC7uGgjE0iDz4Avqi2syiKOzF9ENPxfzm9_tJrpQj-IeTe2lObdcH_jhUJua-scrWQe5Yl5P57MSlUbGd2NtRkpu2sqQxlFfmQV10HYrX7CLTsjdX8NG4UkQXs7KBJ7b0eVk-XSNj-9viE9rM_YzCuZlhR3G3Wy5ko7uDkjQZGZ-OK8cKzCjXSeGXYOmEwh8uXFPfHIex3oY4p3i7SW5BWWfsN2YjHtrOi2N32Hp8ehsXXnrqe7kItik9CLtnVpfdWyA0kPFbuLkYMZLwD9rJcf3sGIWeieIBfvj0PMKaQ7CT2k5DrvVV1zE18-vRCQq4Z7Lo57vz2L3e--Net4QdJrSUIKb98nO3Q9pGgUScEBSdljb7lK9Clw1xw_q9SNqHOP8yb4f9XTtqUri0qF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