<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96014>96014</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DebugInfo][DivRemPairs] Missing debug location updates
</td>
</tr>
<tr>
<th>Labels</th>
<td>
debuginfo,
llvm:transforms
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Apochens
</td>
</tr>
</table>
<pre>
**DivRemPairs-[L207](https://github.com/llvm/llvm-project/blob/3417ff6b1c6b165fce92e7c647c65466092cf638/llvm/lib/Transforms/Scalar/DivRemPairs.cpp#L207)**
The newly created binary operator `RealRem`, which replaces original rem instruction `RemInst`, has no debug location update.
```c++
Instruction *RealRem = E.isSigned() ? BinaryOperator::CreateSRem(X, Y)
: BinaryOperator::CreateURem(X, Y);
RealRem->setName(RemInst->getName() + ".recomposed");
RealRem->insertAfter(RemInst);
Instruction *OrigRemInst = RemInst;
RemInst = RealRem;
OrigRemInst->replaceAllUsesWith(RealRem);
OrigRemInst->eraseFromParent();
```
**DivRemPairs-[L333](https://github.com/llvm/llvm-project/blob/3417ff6b1c6b165fce92e7c647c65466092cf638/llvm/lib/Transforms/Scalar/DivRemPairs.cpp#L333), [L334](https://github.com/llvm/llvm-project/blob/3417ff6b1c6b165fce92e7c647c65466092cf638/llvm/lib/Transforms/Scalar/DivRemPairs.cpp#L334)**
New mul (`Mul`) and sub (`Sub`) instructions, which replace the original rem instruction (`RemInst`), have no debug location update.
```cpp
Instruction *Mul = BinaryOperator::CreateMul(DivInst, Y);
Instruction *Sub = BinaryOperator::CreateSub(X, Mul);
Mul->insertAfter(RemInst);
Sub->insertAfter(Mul);
Instruction *OrigRemInst = RemInst;
// Update AssertingVH<> with new instruction so it doesn't assert.
RemInst = Sub;
// And replace the original instruction with the new one.
OrigRemInst->replaceAllUsesWith(Sub);
OrigRemInst->eraseFromParent();
```
**DivRemPairs-[L385](https://github.com/llvm/llvm-project/blob/3417ff6b1c6b165fce92e7c647c65466092cf638/llvm/lib/Transforms/Scalar/DivRemPairs.cpp#L385), [L393](https://github.com/llvm/llvm-project/blob/3417ff6b1c6b165fce92e7c647c65466092cf638/llvm/lib/Transforms/Scalar/DivRemPairs.cpp#L393)**
Two new freeze instruction (`FrX` and `FrY`) used by other instructions have no debug location.
```cpp
if (!isGuaranteedNotToBeUndef(X, nullptr, DivInst, &DT)) {
auto *FrX =
new FreezeInst(X, X->getName() + ".frozen", DivInst->getIterator());
DivInst->setOperand(0, FrX);
Sub->setOperand(0, FrX);
}
if (!isGuaranteedNotToBeUndef(Y, nullptr, DivInst, &DT)) {
auto *FrY =
new FreezeInst(Y, Y->getName() + ".frozen", DivInst->getIterator());
DivInst->setOperand(1, FrY);
Mul->setOperand(1, FrY);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMV11P4zgU_TXuizVVYjdfD31ICdlFWpgRhV366CS3jVeuHdkOiPn1KzvpNJTCMNp5AEW0ce89vvfY58RhxvCdBFiiaIWiYsZ62yq9zDtVtyDNrFLN8xKRHJG84I-3sP_GuDZfULT6iwQJigpE0tbaziCaI1IiUu64bftqXqs9IqUQj4ePL51W_0JtESkroSpESroIk-02rsI6rsI42taQEUjqeJHUcbSI4yAj9Tam6QSHu7w7zaTZKr03iJTrmgmmESkn5c3rrkOE-gpJNlSPggIF-V0LWMKTeMa1BmahwRWXTD9j1YFmVmmM4uAWmLiFPYoDRC7wU8vrFmvoBKvBYKX5jksmsIY95tJY3deWKzkk7q-ksWNiywyWCjdQ9TssVM18WN81zMJ8KMdF-qtGZOUuP3o1RSX5WA5GtMCXc27WbsEaRFJEMoxoiVe-ha9jB24haH7h21u7Nkj64MrZOCo8PkY0fyfp_jSJjnUN_8dyviB6acDesD0gko6du8Hdj0FfH1lhRMhcQ632nTKucDIFncBxaUDbfGtBHyGnsSfEfNV8N0Z5cg4ZR-jpb8OavuxlguAKGBc5F-LegPmH29bXMWRO6j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