Issue 91574
Summary [DebugInfo][JumpThreading] Missing debug location updates
Labels new issue
Assignees
Reporter Apochens
    Four missing debug location updates for newly created instructions.

[JumpThreading-L1282](https://github.com/llvm/llvm-project/blob/b52fa9461ab73eaf2d04f32c806a1715b2595830/llvm/lib/Transforms/Scalar/JumpThreading.cpp#L1282): The newly created CastInst, which is inserted before the replaced old LoadInst `LoadI`.
```C++
if (AvailableVal->getType() != LoadI->getType())
      AvailableVal = CastInst::CreateBitOrPointerCast(
          AvailableVal, LoadI->getType(), "", LoadI->getIterator());
LoadI->replaceAllUsesWith(AvailableVal);
LoadI->eraseFromParent();
```

[JumpThreading-L2983](https://github.com/llvm/llvm-project/blob/b52fa9461ab73eaf2d04f32c806a1715b2595830/llvm/lib/Transforms/Scalar/JumpThreading.cpp#L2983): The newly created PHINode `NewPN`, which is inserted befor the replaced old SelectInst `SI`.
```cpp
PHINode *NewPN = PHINode::Create(SI->getType(), 2, "", SI->getIterator());
NewPN->addIncoming(SI->getTrueValue(), Term->getParent());
NewPN->addIncoming(SI->getFalseValue(), BB);
SI->replaceAllUsesWith(NewPN);
SI->eraseFromParent();
```

[JumpThreading-L3120](https://github.com/llvm/llvm-project/blob/b52fa9461ab73eaf2d04f32c806a1715b2595830/llvm/lib/Transforms/Scalar/JumpThreading.cpp#L3120): Newly created PHINode `NewPN`, which is inserted at the beginning of the parent block of the replaced Instruction `Inst`:
```cpp
BasicBlock::iterator InsertionPoint = BB->getFirstInsertionPt();
assert(InsertionPoint != BB->end() && "Empty block?");
 // Substitute with Phis & remove.
for (auto *Inst : reverse(ToRemove)) {
if (!Inst->use_empty()) {
  PHINode *NewPN = PHINode::Create(Inst->getType(), 2);
 NewPN->addIncoming(UnguardedMapping[Inst], UnguardedBlock);
 NewPN->addIncoming(GuardedMapping[Inst], GuardedBlock);
 NewPN->insertBefore(InsertionPoint);
 Inst->replaceAllUsesWith(NewPN);
}
  Inst->dropDbgRecords();
 Inst->eraseFromParent();
}
```

I will give a patch for them later.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to