<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 --- - A cast<> failed in ExtractLoops()"
   href="https://llvm.org/bugs/show_bug.cgi?id=28783">28783</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>A cast<> failed in ExtractLoops()
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </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>bugpoint
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>feishenniubi@gmail.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=16845" name="attach_16845" title="The input .ll file that triggered the bug">attachment 16845</a> <a href="attachment.cgi?id=16845&action=edit" title="The input .ll file that triggered the bug">[details]</a></span>
The input .ll file that triggered the bug

I tried to use bugpoint to help me pinpoint a miscompilation bug in loop
optimizers, yet bugpoint itself crashes when trying to extract loops from the
miscompiled function.

The source of the error can be narrowed down to the ExtractLoops() function
inside Miscompilation.cpp. Around line 339 there's a statement
"MiscompiledFunctions[i] = cast<Function>(VMap[MiscompiledFunctions[i]]);". The
right-hand-side of this statement, i.e. VMap[...], turns out to be an empty
WeakVH rather than a Function*. 

This is how I invoked bugpoint: 
<span class="quote">> bugpoint -run-llc -safe-run-llc test.ll -loop-unroll -gcc=clang++</span >

This is what I got back from the invocation:

Read input file      : 'test.ll'
*** All input ok
Running selected passes on program to test for crash: Success!
Initializing execution environment: Found llc:
/home/grieve/LLVM/GSoC/Testing/debugBuild/bin/llc
Running the code generator to test for a crash: <llc>
Generating reference output from raw program: <llc><llc><CC><program>
Reference output is: bugpoint.reference.out-17cf006

*** Checking the code generator...
<llc><CC><program>
*** Output matches: Debugging miscompilation!
Checking to see if '' compiles correctly: <llc><CC><program> yup.
Checking to see if '-loop-unroll' compiles correctly: <llc><CC><program> nope.

*** Found miscompiling pass: -loop-unroll
Emitted bitcode to 'bugpoint-passinput.bc'

*** You can reproduce the problem with: opt bugpoint-passinput.bc -loop-unroll
Checking to see if the program is misoptimized when these functions are run
through the pass: main _ZNSt5dequeIdSaIdEE18_M_fill_initializeERKd
_ZNSt11_Deque_baseIdSaIdEE17_M_initialize_mapEm
_ZNSt11_Deque_baseIdSaIdEE15_M_create_nodesEPPdS3_ __clang_call_terminate
  Optimizing functions being tested: done.
  Checking to see if the merged program executes correctly: <llc><CC><program>
nope.
Checking to see if the program is misoptimized when these functions are run
through the pass: _ZNSt11_Deque_baseIdSaIdEE17_M_initialize_mapEm
_ZNSt11_Deque_baseIdSaIdEE15_M_create_nodesEPPdS3_ __clang_call_terminate
  Optimizing functions being tested: done.
  Checking to see if the merged program executes correctly: <llc><CC><program>
yup.
Checking to see if the program is misoptimized when these functions are run
through the pass: main _ZNSt5dequeIdSaIdEE18_M_fill_initializeERKd
  Optimizing functions being tested: done.
  Checking to see if the merged program executes correctly: <llc><CC><program>
nope.
Checking to see if the program is misoptimized when this function is run
through the pass: _ZNSt5dequeIdSaIdEE18_M_fill_initializeERKd
  Optimizing functions being tested: done.
  Checking to see if the merged program executes correctly: <llc><CC><program>
yup.
Checking to see if the program is misoptimized when this function is run
through the pass: main
  Optimizing functions being tested: done.
  Checking to see if the merged program executes correctly: <llc><CC><program>
nope.

*** The following function is being miscompiled:  main
Extracted a loop from the breaking portion of the program.
<llc><CC><program>bugpoint:
/home/grieve/LLVM/GSoC/Testing/llvm/include/llvm/Support/Casting.h:81: static
bool llvm::isa_impl_cl<To, From*>::doit(const From*) [with To = llvm::Function;
>From = llvm::Value]: Assertion `Val && "isa<> used on a null pointer"' failed.
#0 0x00007f55eba74f38 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/grieve/LLVM/GSoC/Testing/llvm/lib/Support/Unix/Signals.inc:402:0
#1 0x00007f55eba75298 PrintStackTraceSignalHandler(void*)
/home/grieve/LLVM/GSoC/Testing/llvm/lib/Support/Unix/Signals.inc:470:0
#2 0x00007f55eba73548 llvm::sys::RunSignalHandlers()
/home/grieve/LLVM/GSoC/Testing/llvm/lib/Support/Signals.cpp:44:0
#3 0x00007f55eba74896 SignalHandler(int)
/home/grieve/LLVM/GSoC/Testing/llvm/lib/Support/Unix/Signals.inc:256:0
#4 0x00007f55ea594cb0 (/lib/x86_64-linux-gnu/libc.so.6+0x36cb0)
#5 0x00007f55ea594c37 gsignal
/build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#6 0x00007f55ea598028 abort
/build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
#7 0x00007f55ea58dbf6 __assert_fail_base
/build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0
#8 0x00007f55ea58dca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#9 0x0000000000483bc4 (bugpoint+0x483bc4)
#10 0x000000000047fd31 (bugpoint+0x47fd31)
#11 0x000000000047bc43 (bugpoint+0x47bc43)
#12 0x0000000000476bd0 (bugpoint+0x476bd0)
#13 0x000000000046fbcc (bugpoint+0x46fbcc)
#14 0x000000000049ca8d (bugpoint+0x49ca8d)
#15 0x000000000049e540 (bugpoint+0x49e540)
#16 0x000000000049eca3 (bugpoint+0x49eca3)
#17 0x0000000000463318 (bugpoint+0x463318)
#18 0x00000000004b1d61 (bugpoint+0x4b1d61)
#19 0x00007f55ea57ff45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#20 0x0000000000462529 (bugpoint+0x462529)
Stack dump:
0.    Program arguments: bugpoint -run-llc -safe-run-llc test.ll -loop-unroll
-gcc=clang++</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>