<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Scalarizer is crashing"
   href="https://llvm.org/bugs/show_bug.cgi?id=28108">28108</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Scalarizer is crashing
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </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>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16525" name="attach_16525" title="Reproducer ll file">attachment 16525</a> <a href="attachment.cgi?id=16525&action=edit" title="Reproducer ll file">[details]</a></span>
Reproducer ll file

opt -S -scalarizer red.ll

gives

opt: ../include/llvm/Support/Casting.h:95: static bool
llvm::isa_impl_cl<llvm::Instruction, const llvm::Value *>::doit(const From *)
[To = llvm::Instruction, From = const llvm::Value *]: Assertion `Val && "isa<>
used on a null pointer"' failed.
#0 0x000000000175e648 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(build-all/bin/opt+0x175e648)
#1 0x000000000175c8c6 llvm::sys::RunSignalHandlers()
(build-all/bin/opt+0x175c8c6)
#2 0x000000000175f1ca SignalHandler(int) (build-all/bin/opt+0x175f1ca)
#3 0x00007fdd91ba1330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007fdd90dc9c37 gsignal
/build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fdd90dcd028 abort
/build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fdd90dc2bf6 __assert_fail_base
/build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fdd90dc2ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x00000000016aea11 (anonymous
namespace)::Scalarizer::gather(llvm::Instruction*,
llvm::SmallVector<llvm::Value*, 8u> const&) (build-all/bin/opt+0x16aea11)
#9 0x00000000016ad942 llvm::InstVisitor<(anonymous namespace)::Scalarizer,
bool>::visit(llvm::Instruction&) (build-all/bin/opt+0x16ad942)
#10 0x00000000016aaef3 (anonymous
namespace)::Scalarizer::runOnFunction(llvm::Function&)
(build-all/bin/opt+0x16aaef3)
#11 0x00000000013650f8 llvm::FPPassManager::runOnFunction(llvm::Function&)
(build-all/bin/opt+0x13650f8)
#12 0x000000000136533b llvm::FPPassManager::runOnModule(llvm::Module&)
(build-all/bin/opt+0x136533b)
#13 0x00000000013657f5 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(build-all/bin/opt+0x13657f5)
#14 0x0000000000643f40 main (build-all/bin/opt+0x643f40)
#15 0x00007fdd90db4f45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#16 0x00000000006346c5 _start (build-all/bin/opt+0x6346c5)
Stack dump:
0.      Program arguments: build-all/bin/opt -S -scalarizer red.ll 
1.      Running pass 'Function Pass Manager' on module 'red.ll'.
2.      Running pass 'Scalarize vector operations' on function '@f4'
Abort

It's a cast in the Scalarizer::gather that crashes:

  // If we already have a scattered form of Op (created from ExtractElements
  // of Op itself), replace them with the new form.
  ValueVector &SV = Scattered[Op];
  if (!SV.empty()) {
    for (unsigned I = 0, E = SV.size(); I != E; ++I) {
      Instruction *Old = cast<Instruction>(SV[I]);
      CV[I]->takeName(Old);
      Old->replaceAllUsesWith(CV[I]);
      Old->eraseFromParent();
    }
  }

SV[I] is null so

      Instruction *Old = cast<Instruction>(SV[I]);

doesn't succeed.

The Scalarizer doesn't say anything with -debug turned on.

Changing the cast to

      Value *V = SV[I];
      if (V == nullptr)
        continue;

      Instruction *Old = cast<Instruction>(V);

makes the program compile but I have no idea if the output is ok then.</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>