<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 - [MCA] ResourceManager::selectPipe assertion failure "No available units to select!""
   href="https://bugs.llvm.org/show_bug.cgi?id=50725">50725</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[MCA] ResourceManager::selectPipe assertion failure "No available units to select!"
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>llvm-mca
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>minyihh@uci.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>andrea.dibiagio@gmail.com, llvm-bugs@lists.llvm.org, matthew.davis@sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24957" name="attach_24957" title="input file that reproduces the crash">attachment 24957</a> <a href="attachment.cgi?id=24957&action=edit" title="input file that reproduces the crash">[details]</a></span>
input file that reproduces the crash

When running with command:
```
llvm-mca -mtriple=x86_64-pc-linux-gnu -mcpu=skylake --iterations=1 <attachment
file>
```
(I wish I could reduce the input further, but the original input was like 200k
lines. Here is the same input file on gist:
<a href="https://gist.github.com/mshockwave/ffcd56c83e1897b23c1835ae2eec2b89">https://gist.github.com/mshockwave/ffcd56c83e1897b23c1835ae2eec2b89</a>)
It gives us the following assertion failure:
```
llvm/lib/MCA/HardwareUnits/ResourceManager.cpp:181: llvm::mca::ResourceRef
llvm::mca::ResourceManager::selectPipe(uint64_t): Assertion `RS.isReady() &&
"No available units to select!"' failed.
...
#10 0x00007fb14f60c549 llvm::mca::ResourceManager::selectPipe(unsigned long)
(.localalias) llvm-project/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp:181:3
#11 0x00007fb14f60cd0d
llvm::mca::ResourceManager::issueInstruction(llvm::mca::InstrDesc const&,
llvm::SmallVectorImpl<std::pair<std::pair<unsigned long, unsigned long>,
llvm::mca::ResourceCycles> >&)
llvm-project/llvm/lib/MCA/HardwareUnits/ResourceManager.cpp:309:44
#12 0x00007fb14f61495b
llvm::mca::Scheduler::issueInstructionImpl(llvm::mca::InstRef&,
llvm::SmallVectorImpl<std::pair<std::pair<unsigned long, unsigned long>,
llvm::mca::ResourceCycles> >&)
llvm-project/llvm/lib/MCA/HardwareUnits/Scheduler.cpp:83:14
#13 0x00007fb14f614b4e
llvm::mca::Scheduler::issueInstruction(llvm::mca::InstRef&,
llvm::SmallVectorImpl<std::pair<std::pair<unsigned long, unsigned long>,
llvm::mca::ResourceCycles> >&, llvm::SmallVectorImpl<llvm::mca::InstRef>&,
llvm::SmallVectorImpl<llvm::mca::InstRef>&)
llvm-project/llvm/lib/MCA/HardwareUnits/Scheduler.cpp:117:3
#14 0x00007fb14f63321b
llvm::mca::ExecuteStage::issueInstruction(llvm::mca::InstRef&)
llvm-project/llvm/lib/MCA/Stages/ExecuteStage.cpp:59:39
#15 0x00007fb14f633549 llvm::mca::ExecuteStage::issueReadyInstructions()
llvm-project/llvm/lib/MCA/Stages/ExecuteStage.cpp:90:41
...
```

The root cause is the `fxrstor 64(%rsp)` instruction on line 257. FXRSTOR
instruction consume 7 resources: SKLPort0, Port6, Port05, Port06, Port15,
Port23, and Port0156.
The issue occurred when ResourceManager tried to acquire Port15. Before this
instruction was executed, Port1 has been acquired by some other instructions,
and Port5 would be acquired by Port05 group in FXRSTOR, so ResourceManager
failed to acquire Port15.

My ball-park guessing is that Port15 should be marked reserved (which it is not
right now), although I'm not really sure how resource reservation works in
scheduling / MCA.

I'll keep posted here</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>