<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Asserts in SelectionDAGISel::LowerArguments erroneously (?) hidden behind "-debug" flag, hiding "bugs" in at least two backends"
   href="https://bugs.llvm.org/show_bug.cgi?id=40457">40457</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Asserts in SelectionDAGISel::LowerArguments erroneously (?) hidden behind "-debug" flag, hiding "bugs" in at least two backends
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mikael.holmen@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Reproduce with:
 llc test/CodeGen/AArch64/aarch-multipart.ll -o - -debug

which yields

Creating new node: t27: v2i64,ch = load<(load 16 from %fixed-stack.0)> t0,
FrameIndex:i64<-1>, undef:i64
Creating new node: t29: v2i64,ch = load<(load 16 from %fixed-stack.0)> t0,
FrameIndex:i64<-2>, undef:i64
llc: ../lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:9110: void
llvm::SelectionDAGISel::LowerArguments(const llvm::Function &): Assertion
`EVT(Ins[i].VT) == InVals[i].getValueType() && "LowerFormalArguments emitted a
value with the wrong type!"' failed.
Stack dump:
0.      Program arguments: /data/repo/master/llvm-master/build-all/bin/llc
test/CodeGen/AArch64/aarch-multipart.ll -o - -debug 
1.      Running pass 'Function Pass Manager' on module
'test/CodeGen/AArch64/aarch-multipart.ll'.
2.      Running pass 'AArch64 Instruction Selection' on function
'@caller_function'
 #0 0x0000000002223fd4 PrintStackTraceSignalHandler(void*)
(/data/repo/master/llvm-master/build-all/bin/llc+0x2223fd4)
 #1 0x0000000002221fe0 llvm::sys::RunSignalHandlers()
(/data/repo/master/llvm-master/build-all/bin/llc+0x2221fe0)
 #2 0x0000000002224338 SignalHandler(int)
(/data/repo/master/llvm-master/build-all/bin/llc+0x2224338)
 #3 0x00007f05c9fc8330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
 #4 0x00007f05c8bb7c37 gsignal
/build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
 #5 0x00007f05c8bbb028 abort
/build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
 #6 0x00007f05c8bb0bf6 __assert_fail_base
/build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
 #7 0x00007f05c8bb0ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
 #8 0x0000000002066ab5 llvm::SelectionDAGISel::LowerArguments(llvm::Function
const&) (/data/repo/master/llvm-master/build-all/bin/llc+0x2066ab5)
 #9 0x00000000020cb9f1
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/data/repo/master/llvm-master/build-all/bin/llc+0x20cb9f1)
#10 0x00000000020c9bcc
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/data/repo/master/llvm-master/build-all/bin/llc+0x20c9bcc)
#11 0x00000000018d004d
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/data/repo/master/llvm-master/build-all/bin/llc+0x18d004d)
#12 0x0000000001c137cd llvm::FPPassManager::runOnFunction(llvm::Function&)
(/data/repo/master/llvm-master/build-all/bin/llc+0x1c137cd)
#13 0x0000000001c13a88 llvm::FPPassManager::runOnModule(llvm::Module&)
(/data/repo/master/llvm-master/build-all/bin/llc+0x1c13a88)
#14 0x0000000001c13eea llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/data/repo/master/llvm-master/build-all/bin/llc+0x1c13eea)
#15 0x0000000000747d0b compileModule(char**, llvm::LLVMContext&)
(/data/repo/master/llvm-master/build-all/bin/llc+0x747d0b)
#16 0x0000000000745400 main
(/data/repo/master/llvm-master/build-all/bin/llc+0x745400)
#17 0x00007f05c8ba2f45 __libc_start_main
/build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#18 0x000000000074325a _start
(/data/repo/master/llvm-master/build-all/bin/llc+0x74325a)
Abort

while just
  llc test/CodeGen/AArch64/aarch-multipart.ll -o - 
passes succesfully.

The assertion that fails is the second one of

  LLVM_DEBUG({
    for (unsigned i = 0, e = Ins.size(); i != e; ++i) {
      assert(InVals[i].getNode() &&
             "LowerFormalArguments emitted a null value!");
      assert(EVT(Ins[i].VT) == InVals[i].getValueType() &&
             "LowerFormalArguments emitted a value with the wrong type!");
    }
  });

in SelectionDAGISel::LowerArguments and I suppose someone rather wanted to do
something like
 #ifndef NDEBUG
 ...
 #endif
around the loop rather than hiding it behind -debug.

Note that if we always activate the asserts the following lit tests fail:
    LLVM :: CodeGen/AArch64/aarch-multipart.ll
    LLVM :: CodeGen/AArch64/argument-blocks.ll
    LLVM :: CodeGen/AArch64/arm64-aapcs.ll
    LLVM :: CodeGen/AMDGPU/function-args.ll

The problem seems to be types that are handled with CCBitConvertToType in the
calling convention, like

  CCIfType<[v2f64, v4f32], CCBitConvertToType<v2i64>>,

but then lack a corresponding bitcast in the target's LowerFormalArguments
method.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>