<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/63220>63220</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [PowerPC] call to _mcount emitted by -pg needs to be emitted BEFORE function prolog
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:PowerPC
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nickdesaulniers
      </td>
    </tr>
</table>

<pre>
    From an LKML thread: https://lore.kernel.org/llvm/20230609034501.407971-1-naveen@kernel.org/

```
Ftrace on ppc32 expects a three instruction sequence at the beginning of
each function when specifying -pg:
        mflr    r0
        stw     r0,4(r1)
        bl      _mcount

This is the case with all supported versions of gcc. Clang however emits
a branch to _mcount after the function prologue
```
As a result, support for function tracing is being disabled in the linux kernel for ppc32 when built with clang.

cc @nemanjai @nemanja-ibm 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsU11vozoQ_TXmZRTkGELggYc0LS-3V7e62veVbQZwa2zWH0n771cmaZquVooiM-MZzzlnDvdejQaxJbsHsnvMeAyTda1R8q1Hz6M2Cp3PhO0_2s7ZGbiB53_-fYYwOeQ9KQ4whbB4UhwI6wjrtHWYv6EzqHPrxhTRp5mwjlFW0Io2tCh3dJuXdN_st5vtxvAToiEl_VZE6COhh-t_Ra-_9bMLjksEa2BZZMEA3xeUwQNfZ0JQxgcXZVDWgMdfEY1E4AHChCBwVMYoM4IdLt2QywmGaC73zxMa8AtKNXykW5tlTMiuwzTzoB2hjaO3iA_nS4AdS8JqtyWsuSWFJrT5OUsbTbgH9GNSHpRfJ5LcI5xVmIBrDT4ui3UBezih88oaD3aAUcocjpqbESZ7xhM6wFkFf-nGQThu5ATBwvUx4ENAt_a_QVuc1XaM-FdOD4k-hz7qQNjxcwwYrPtqkGhPnCgPAtOhV54LjT0osz6llYnvcJFxLb3os3IqotLhglMmIPk9H1ICKanBmZtXru7OGyVmyPq26Jui4Rm226quiqKp2T6bWlb1WA9139dC7PoSa17TYSgLSatdv6csU-3n0m2bsij3-VCJph8aVlO55fuhISXFmSudpx1Nm5cp7yO2VcEYzTQXqP3qDMYEl29o0sK_2DO6lyNhLBnGtal2I-LoSUm18sF_dQsq6NVanzW7R5BJ5zupkpJJcPGRtg0MYu9TXuAt9fDU_ff_059SZtHp9rv5RhWmKHJp5y_freMtzr6iDIR1K0BPWLdi_B0AAP__yHhJEg">