<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 - Segmentation fault in NaryReassociate pass"
   href="https://bugs.llvm.org/show_bug.cgi?id=37539">37539</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segmentation fault in NaryReassociate pass
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>karl-johan.karlsson@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When running the testcase:
-------------------------------------------------
; RUN: opt < %S -nary-reassociate -S -o /dev/null

define void @f1() {
  br label %bb1

bb1:                                              ; preds = %bb1, %0
  %1 = phi i16 [ 0, %0 ], [ %3, %bb1 ]
  %2 = phi i16 [ 0, %0 ], [ %4, %bb1 ]
  %scevgep.offs = add i16 2, 0
  %3 = add i16 %1, %scevgep.offs
  %scevgep.offs5 = add i16 2, 0
  %4 = add i16 %2, %scevgep.offs5
  br i1 false, label %bb1, label %bb7

bb7:                                              ; preds = %bb1
  ret void
}
-------------------------------------------------
you end up with a segv.

$ ./opt -nary-reassociate -S -o - foo.ll
Stack dump:
0.      Program arguments: ./opt -nary-reassociate -S -o - foo.ll 
1.      Running pass 'Function Pass Manager' on module 'foo.ll'.
2.      Running pass 'Nary reassociation' on function '@f1'
#0 0x0000000002186074 PrintStackTraceSignalHandler(void*) (./opt+0x2186074)
#1 0x0000000002184350 llvm::sys::RunSignalHandlers() (./opt+0x2184350)
#2 0x00000000021863d8 SignalHandler(int) (./opt+0x21863d8)
#3 0x00007f707bea5330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x0000000002037ecd
llvm::NaryReassociatePass::doOneIteration(llvm::Function&) (./opt+0x2037ecd)
#5 0x000000000203ac08 (anonymous
namespace)::NaryReassociateLegacyPass::runOnFunction(llvm::Function&)
(./opt+0x203ac08)
#6 0x0000000001c19928 llvm::FPPassManager::runOnFunction(llvm::Function&)
(./opt+0x1c19928)
#7 0x0000000001c19b68 llvm::FPPassManager::runOnModule(llvm::Module&)
(./opt+0x1c19b68)
#8 0x0000000001c1a045 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(./opt+0x1c1a045)
#9 0x000000000077658c main (./opt+0x77658c)
#10 0x00007f707aa7ff45 __libc_start_main
/build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#11 0x000000000075fabd _start (./opt+0x75fabd)
Segmentation fault (core dumped)</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>