<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 - [MachineOutliner][AArch64] Improve the state of stack fixups."
   href="https://bugs.llvm.org/show_bug.cgi?id=46767">46767</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[MachineOutliner][AArch64] Improve the state of stack fixups.
          </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>All
          </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>Backend: AArch64
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>puyan@puyan.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>arnaud.degrandmaison@arm.com, llvm-bugs@lists.llvm.org, smithp352@googlemail.com, Ties.Stuij@arm.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23748" name="attach_23748" title="To Repro: llc -o - ld-temp-named.ll">attachment 23748</a> <a href="attachment.cgi?id=23748&action=edit" title="To Repro: llc -o - ld-temp-named.ll">[details]</a></span>
To Repro: llc -o - ld-temp-named.ll

The MachineOutliner on AArch64 hits an assert for cases where there are stack
fixups required for the default FrameID type MachineOutlinerDefault.

This is set in llvm/lib/Target/AArch64/AArch64InstrInfo.cpp at
AArch64InstrInfo::getOutliningCandidateInfo() in cases where an outliner
candidates that has a noreturn caller, no LR, no spare general purpose
registers, and no use of SP. When the outliner here sets the candidate type to
MachineOutlinerDefault, it his highly likely that an assert is hit in the same
file at AArch64InstrInfo::buildOutlinedFrame():

```
    assert(OF.FrameConstructionID != MachineOutlinerDefault &&
           "Can only fix up stack references once")
```

In the the cases where the candidate has a call or a noreturn caller I have a
patch for the outliner to bail out: <a href="https://reviews.llvm.org/D83923">https://reviews.llvm.org/D83923</a>



>From speaking with @paquette it sounds like the assert is there because we want
to know when these cases happen since this two pass stack fixup path is not
adequately tested and checked for any potential illegal code that may be
generated.

So I filed _this_ bug to track the progress of this scenario, and to reference
the bugzilla ID in comments associated with this issue. 

I originally hit the assert when building the llvm test suite for
aarch64-unknown-linux-gnu with -Oz and -flto=full. I have a reduced IR from the
test that caused the assert attached (MultiSource/Applications/Burg). Some of
my colleagues also hit it with -flto=thin when building some apps internally.</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>