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

    <tr>
        <th>Summary</th>
        <td>
            [AArch64] [Clang] How to prevent Clang from using the LR register for intermediate calculations.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    ![image](https://github.com/llvm/llvm-project/assets/81171521/9c1523aa-74f2-439b-9a20-014ce368dfe5)
Hello, I have found that when clang is enabled with the -Oz option, the LR register will be used for computation (rather than just storing the return address). Although I can understand the benefits of doing this for code size, it has caused some difficulties for my work. How can I disable this optimization while still enabling -Oz?

If there are no relevant options, could you please provide me with some information about this optimization? Perhaps I can manage it by directly modifying the compiler.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUU02r6zYQ_TXyZkiwZTuJF17kvhDehcIr7arLsTS29CpLQRol5P76IudeWujqbWwQmjkfOgdTsosnGkX_JvpLhZlNiONfGf2fButqCvo5CtmI_s2uuJDoL0KeDPMtifYs5FXI62LZ5Gmvwirk1bn71293i-EnKRbyiikRJyGvp6Y5Nr1shLwOqulli7g7drPcde0w7QaU9a5uOkXt4aRn6oUcRH0R9fk7OReE_AbvYPBOMIfsNbBBhochD8qhX8AmII-TIw0PywbYEOx-fEC4sQ2-jJeT3_6ASItNTBEe1jmYCHIiDXOIoMJ6y4zlPgh5isiGYgHy8DMnhsQhWr9siyJxjh5Q60gpCTns4ezYhLwYeAeFHrLXFBPjxpVgIk-z5QRhBh1ea2z6xNUEyX5QYWkZDCZQuNFKYSXQdp6tyo4tvQbWJzxC_HsP38Njw3oHbVMR_1paNK_246XkYawjSFzUbg4V7N2PD9FeX_6-vu9zoRkJMBL4AJEc3dHzp4GpcFMhOw3PkOHmCBPBLYa71QQrvUzf6Fo_h7i-wHEKmf9PSrRX-J2iwVv6dGtFjwsV9dMTtI2k2D1hDdrOzy_Py_tYR3Ff6bHVQztgRWNzbOThWPdDXZkR8XQY6oNSDR77QfVaqk7NU4ONpLaWTWVHWcuu7uqhabuhr_fHtj606iBPc6PUERvR1bSidfuS4n2IS2VTyjSeTo3sK4cTubQVRsotd0LK0p04bqmf8pJEVzubOP27gS27rWXnc1Tm0In-AqJ_-7bN95ftFTnALdKdPMN2DnMMK-T0pf2_wS0RsJ4prqQtMoFCp7LbnE37Kkc3_nJLN5VbS4vQfwIAAP__5YRgYw">