<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/129503>129503</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Debug location mismatch after argument promotion pass
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
afikcohen1
</td>
</tr>
</table>
<pre>
When ArgumentPromotionPass optimizes a function, it changes some arguments to be passed by value instead of by pointer or reference. As part of this optimization, it creates a load instruction before the function call and removes the original load inside the function. However, the debug location of the new load instruction is incorrectly set to the location of the call instruction, instead of the original load inside the function. This results in incorrect debug information and makes it harder to trace the source code during debugging.
https://godbolt.org/z/7d969doK6
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMk82OnDAQhJ_GXFo7Mob54cBhkhWKlMseIuXc2A04a9zINrPaffrIzOxvLjmNNO2q-ii3MUY7eqJW7L-J_X2Ba5o4tDjYR80T-bLo2Ty3vyfycA7jOpNPD4FnTpb9A8YIvCQ72xeKgDCsXueBUN_BJtAT-pEiRJ4J8KaOkBh6ggVjJAP9M1zQrQTWx0RogIf838LWJwrAAQINFMhr2sE5woIh5TNpsm_Z-DEzEKYNxjGazTWsGxT0NHAgSBO9gYJG5wC9gUAzXyhuUw52tB7dm4U1n2U7-MFPdKGQQ_PAUL-O4FhvKFc-Ak9P_1LYCNZrDoF0cs8QKeVC8vGv8o3tg3T7wveW_pP0Vy4qUFxdysnv4Tdo6wcO8zU4FzHjI8Xc5ITBUNjgAuqrbeQ1aALNhsCswfrx6jJaP-6EPAt5nlJaoqjOQnVCdSObnl3acRiF6l6E6o6mOTSGfx4K01amqRosqC2PtWyakzzVxdT2pWxKWR4IT8fqUPd6MLTHypyOTS3LQ1PYVkm1l5WsSlnVdb1rGkUoteprdSqNQVFLmtG6nXOXOWcXNsaV2lI1e1kVDntycVt5pfIlbVOhVH4Boc2iu34do6ilszHFd5tkk6P2_vNtzzbOmPQEOOSVfV10WF7fybbrxRpc-6Ucm6a132mehepyxu3nbgn8h3QSqtvIolDdDf3Sqr8BAAD__-5aSvc">