<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 - [llvm-mca] crashes in ResourceManager::mustIssueImmediately()"
   href="https://bugs.llvm.org/show_bug.cgi?id=37643">37643</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[llvm-mca] crashes in ResourceManager::mustIssueImmediately()
          </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>TableGen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>lebedev.ri@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20367" name="attach_20367" title="the sched model that causes the crash">attachment 20367</a> <a href="attachment.cgi?id=20367&action=edit" title="the sched model that causes the crash">[details]</a></span>
the sched model that causes the crash

I don't know if this is actually a mca bug, or maybe tablegen should
have somehow handled it.
I also don't quite have a good reproducer, since this happens on
my WIP-and-broken bdver2 sched model.

If you apply the patch, and run:
$ llvm-mca -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver2 -iterations=10000
-timeline-max-cycles=80 -timeline-max-iterations=20 -all-stats -all-views new.s

It will crash:
$ /build/llvm-build-Clang6-release/bin/llvm-mca
-mtriple=x86_64-unknown-linux-gnu -mcpu=bdver2 -iterations=10000
-timeline-max-cycles=80 -timeline-max-iterations=20 -all-stats -all-views
/tmp/new.s 
llvm-mca: /build/llvm/tools/llvm-mca/Scheduler.cpp:169: auto
mca::ResourceManager::mustIssueImmediately(const mca::InstrDesc &)::(anonymous
class)::operator()(const unsigned int) const: Assertion `Resources[BufferMask]
&& "crash!"' failed.
Stack dump:
0.      Program arguments: /build/llvm-build-Clang6-release/bin/llvm-mca
-mtriple=x86_64-unknown-linux-gnu -mcpu=bdver2 -iterations=10000
-timeline-max-cycles=80 -timeline-max-iterations=20 -all-stats -all-views
/tmp/new.s 
#0 0x00007f9fad035884 PrintStackTraceSignalHandler(void*)
(/build/llvm-build-Clang6-release/bin/../lib/libLLVMSupport.so.7+0x13d884)
#1 0x00007f9fad03376e llvm::sys::RunSignalHandlers()
(/build/llvm-build-Clang6-release/bin/../lib/libLLVMSupport.so.7+0x13b76e)
#2 0x00007f9fad035a42 SignalHandler(int)
(/build/llvm-build-Clang6-release/bin/../lib/libLLVMSupport.so.7+0x13da42)
#3 0x00007f9facca1f50 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11f50)
#4 0x00007f9fabfcce7b gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x34e7b)
#5 0x00007f9fabfce231 abort (/lib/x86_64-linux-gnu/libc.so.6+0x36231)
#6 0x00007f9fabfc59da (/lib/x86_64-linux-gnu/libc.so.6+0x2d9da)
#7 0x00007f9fabfc5a52 (/lib/x86_64-linux-gnu/libc.so.6+0x2da52)
#8 0x000000000022d2c8 bool
__gnu_cxx::__ops::_Iter_negate<mca::ResourceManager::mustIssueImmediately(mca::InstrDesc
const&)::$_1>::operator()<__gnu_cxx::__normal_iterator<unsigned long const*,
std::vector<unsigned long, std::allocator<unsigned long> > >
<span class="quote">>(__gnu_cxx::__normal_iterator<unsigned long const*, std::vector<unsigned long,</span >
std::allocator<unsigned long> > >)
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x22d2c8)
#9 0x000000000022a6cf mca::ResourceManager::mustIssueImmediately(mca::InstrDesc
const&) (/build/llvm-build-Clang6-release/bin/llvm-mca+0x22a6cf)
#10 0x000000000022b417 mca::Scheduler::scheduleInstruction(mca::InstRef&)
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x22b417)
#11 0x0000000000216b78 mca::DispatchStage::dispatch(mca::InstRef)
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x216b78)
#12 0x0000000000216c5c mca::DispatchStage::execute(mca::InstRef&)
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x216c5c)
#13 0x00000000002152bf mca::Backend::runCycle(unsigned int)
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x2152bf)
#14 0x00000000002151f7 mca::Backend::run()
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x2151f7)
#15 0x0000000000221149 main
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x221149)
#16 0x00007f9fabfb9a87 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21a87)
#17 0x000000000021502a _start
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x21502a)
Aborted

Somehow even if the sched model is broken (it surely is, i don't know what i'm
doing :),
it shouldn't crash, probably, i think.</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>