<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96841>96841</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DebugInfo][SeparateConstOffsetFromGEP] Missing debug location updates for sext instructions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Apochens
</td>
</tr>
</table>
<pre>
[**SeparateConstOffsetFromGEP-L1237**](https://github.com/llvm/llvm-project/blob/c791d86eab13634ec372196977eeac8f3e9f4805/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L1237)
The new sext instruction `NewSExt` replaces the original add instruction `I`, but the debug location of `I` does not be propagated to `NewSExt`:
```cpp
Instruction *NewSExt =
new SExtInst(Dom, I->getType(), "", I->getIterator());
NewSExt->takeName(I);
I->replaceAllUsesWith(NewSExt);
RecursivelyDeleteTriviallyDeadInstructions(I);
```
[**SeparateConstOffsetFromGEP-L1249**](https://github.com/llvm/llvm-project/blob/c791d86eab13634ec372196977eeac8f3e9f4805/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp#L1249)
The new sext instruction `NewSExt` replaces the original sub instruction `I`, but the debug location of `I` does not be propagated to `NewSExt`:
```cpp
Instruction *NewSExt =
new SExtInst(Dom, I->getType(), "", I->getIterator());
NewSExt->takeName(I);
I->replaceAllUsesWith(NewSExt);
RecursivelyDeleteTriviallyDeadInstructions(I);
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVU1v2zgQ_TXUhYghkfo86OBY8cLAbnax8WLPI3IksaVFgaSc5N8XlO3ESRGgBXpogQKELXEeZ-Y9vQHBOdWPiDXJbknWRDD7wdh6PRkx4Oii1sjnJcbWhK0fcAILHjdmdP7vrnPot9Yc_rj75-bPhPHihCJZQ1g5eD85wteEbQnb9soPc7sS5kDYVuvj5e9msuYTCk_YttWmJWwriiqRZY7QJjznKQpesKTKq6JABFF2HKsuLePsKo8K5_YWRtcZe3CEbR8EaLDh4cOOV2KaCOPnvisSNyRe7wekIz5Sh0-eqtF5OwuvzEhJHt_j48Pdkyd5TC1OGgQ66gekxqpejaApSPn-zI7kMWEb2s5-wUps555qI2BBmO4CotKgo6PxtEU6WTNBDx4l9eZt6SDo0un5N49PK5BZdnbXDbD1-SQlvDnFKaULw7AbsISVTfgoG7q7IfyuR79_npCwMmjCNpQwtqzX-M6jBW_sBVMRfnvKfS4WcB4-4z0cQqLdNWRJcpZvrfV_Dt3_yg-ElReOV-B_UczWqSPq5wY1etxbdVSgwyvIK6bufZkXXd6I9W02Tqtf08Zp9WLjH2BmN7e_zfyTmTmSNZcVryDCOimSKs2KIk6ioW5l0UneclYksoA2Y0wgJlkHMZNFhV2kahazNM5ZEfO4ZMkKIMkgE4XgEkDmOUljPIDSq2DGlbF9pJybsa7yMk0iDS1qd7oHWBB8CQYpsyay9TIB7dw7ksZaOe9es3jl9XK5NMEsu7EzYayy248NTbKG_qWcU2P_3mHzJMGjo52xX5naRbPV9XdP60IkjNqJ6LFmXwIAAP__6wsxZA">