Issue |
96014
|
Summary |
[DebugInfo][DivRemPairs] Missing debug location updates
|
Labels |
debuginfo,
llvm:transforms
|
Assignees |
|
Reporter |
Apochens
|
**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);
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs