<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96727>96727</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISCV] MachineCopyPropagationPass may cause link time error
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Yunzezhu94
</td>
</tr>
</table>
<pre>
In RISCV target pipeline MachineCopyPropagationPass is placed in addPreEmitPass and after BranchRelaxationPass and RISCVMakeCompressibleOptPass now. I've encountered a unusual case that contains a R_RISCV_BRANCH at maximum jump distance with some Compressed instructions, while MachineCopyPropagationPass breaks generates of some Compressed instructions and make jump distance exceeds maximum jump distance of R_RISCV_BRANCH, and linker reports relocation truncated to fit. It looks BranchRelaxationPass estimates jump distance with Compressed instructions successfully generated, and MachineCopyPropagationPass may make real jump distance differ from estimated jump distance. I wonder if it is better to place MachineCopyPropagationPass earlier in addPreEmitPass prior to BranchRelaxationPass and RISCVMakeCompressibleOptPass, so that BranchRelaxationPass could correctly estimate jump distance of relocations.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVM1u4zYQfhrpMlhBS0v2-qDDxlujPmwbuECBnoIRObIYU6TAGcZxnr6Q3CRoflygJx2o-f7mwyCzPXiiJqtvsvpHjkn6EJu_kn-ipz6tq7wN5tzsPOx3f2z-BMF4IIHRjuSsJ_iJureeNmE838Yw4gHFBn-LzGAZRoeaDFgPaMxtpF8GK_MbegPYCUW4ieh1vyeHj6-j0_PM9xOPtAnDGInZto5-Hy_zPpwK2GVq9UBAXofkhSIZQEg-cUIHGplAehTQwQtaz4Cwv5tR727233_b_AooMOCjHdIA92kYwVgW9JrgZKUHDgPBM_nsgiUmPYnkTG3g1Ft3NYA2Eh4ZDuQpohBD6K6CzrYHPNIbNfSoiQx_ojV0b2xN2iYkZ_2RIkQaQxSGSC7oWRxITF6jkAEJ0FkpYCfgQjjyx-sgFjvMDj6I6TMznLQm5i45d37JwDyLuxLbgOdLCpHQvWE0tusoQhfD8KLK_PufAmAHp-ANRbAdWJmK2JJMZZNwqeQ1esLo7DT7rrRjtGHG-F-dnZxzuFTyQwAdkjOgQ4ykxZ1f_L3f9-squchNszDrxRpzar6uvq4XK1Uu6rxv2k7Xq5YqUrSuy1K1eqWqqjR1tVB1rU1uG1WqqlyqZbmYZor1UpdUVar8Vn3rlFFZVdKA1hXOPQxFiIfcMidq1suVWuUOW3I83w2lPJ1gfsyUms5IbKaZL206cFaVzrLwK4pYcfPBmePK6h__1QaNiWnuM4gdCCjGEPMUXdOLjJwtvmdqm6ntwUqf2kKHIVPbie6fz5cxhnvSkqntLJIztb2YeGjU3wEAAP__ZG7LAQ">