<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] mca::CycleSegment::Subtract(unsigned int): Assertion `End >= Cycles' failed."
   href="https://bugs.llvm.org/show_bug.cgi?id=37661">37661</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[llvm-mca] mca::CycleSegment::Subtract(unsigned int): Assertion `End >= Cycles' failed.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </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>andrea.dibiagio@gmail.com, craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk
          </td>
        </tr>

        <tr>
          <th>Depends on</th>
          <td>37643
          </td>
        </tr></table>
      <p>
        <div>
        <pre>+++ This bug was initially created as a clone of <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - [llvm-mca] crashes in ResourceManager::mustIssueImmediately()"
   href="show_bug.cgi?id=37643">Bug #37643</a> +++

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, it will crash:
$ /build/llvm/utils/update_mca_test_checks.py --llvm-mca-binary
/build/llvm-build-Clang6-release/bin/llvm-mca X86/BdVer2/load-store-alias.s
Test: X86/BdVer2/load-store-alias.s
llvm-mca: /build/llvm/tools/llvm-mca/Instruction.h:228: void
mca::CycleSegment::Subtract(unsigned int): Assertion `End >= Cycles' failed.
Stack dump:
0.      Program arguments: /build/llvm-build-Clang6-release/bin/llvm-mca
-mtriple=x86_64-unknown-unknown -mcpu=bdver2 -iterations=100 -timeline
-timeline-max-iterations=1 -noalias=false 
#0 0x00007f100cc6d874 PrintStackTraceSignalHandler(void*)
(/build/llvm-build-Clang6-release/bin/../lib/libLLVMSupport.so.7+0x13d874)
#1 0x00007f100cc6b75e llvm::sys::RunSignalHandlers()
(/build/llvm-build-Clang6-release/bin/../lib/libLLVMSupport.so.7+0x13b75e)
#2 0x00007f100cc6da32 SignalHandler(int)
(/build/llvm-build-Clang6-release/bin/../lib/libLLVMSupport.so.7+0x13da32)
#3 0x00007f100c8d9f50 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11f50)
#4 0x00007f100bc04e7b gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x34e7b)
#5 0x00007f100bc06231 abort (/lib/x86_64-linux-gnu/libc.so.6+0x36231)
#6 0x00007f100bbfd9da (/lib/x86_64-linux-gnu/libc.so.6+0x2d9da)
#7 0x00007f100bbfda52 (/lib/x86_64-linux-gnu/libc.so.6+0x2da52)
#8 0x00000000002199dd mca::InstrBuilder::createInstrDescImpl(llvm::MCInst
const&) (/build/llvm-build-Clang6-release/bin/llvm-mca+0x2199dd)
#9 0x0000000000219d1f mca::InstrBuilder::createInstruction(llvm::MCInst const&)
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x219d1f)
#10 0x0000000000216de2 mca::FetchStage::execute(mca::InstRef&)
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x216de2)
#11 0x00000000002142e1 mca::Backend::runCycle(unsigned int)
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x2142e1)
#12 0x00000000002141f7 mca::Backend::run()
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x2141f7)
#13 0x000000000022011d main
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x22011d)
#14 0x00007f100bbf1a87 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21a87)
#15 0x000000000021402a _start
(/build/llvm-build-Clang6-release/bin/llvm-mca+0x21402a)
Aborted
Traceback (most recent call last):
  File "/build/llvm/utils/update_mca_test_checks.py", line 497, in <module>
    sys.exit(main())
  File "/build/llvm/utils/update_mca_test_checks.py", line 482, in main
    block_infos = _get_block_infos(run_infos, test_path, args, common_prefix)
  File "/build/llvm/utils/update_mca_test_checks.py", line 258, in
_get_block_infos
    test_path)
  File "/build/llvm/utils/UpdateTestChecks/common.py", line 40, in invoke_tool
    shell=True, stdin=ir_file)
  File "/usr/lib/python2.7/subprocess.py", line 223, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command
'/build/llvm-build-Clang6-release/bin/llvm-mca -mtriple=x86_64-unknown-unknown
-mcpu=bdver2 -iterations=100 -timeline -timeline-max-iterations=1
-noalias=false' returned non-zero exit status 134

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>

        <div id="referenced">
          <hr style="border: 1px dashed #969696">
          <b>Referenced Bugs:</b>
          <ul>
              <li>
                [<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - [llvm-mca] crashes in ResourceManager::mustIssueImmediately()"
   href="https://bugs.llvm.org/show_bug.cgi?id=37643">Bug 37643</a>] [llvm-mca] crashes in ResourceManager::mustIssueImmediately()
              </li>
          </ul>
        </div>
        <br>

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

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