Issue 97559
Summary [DebugInfo][SimpleLoopUnswitch] Missing debug location updates (Part 1)
Labels debuginfo, llvm:transforms
Assignees
Reporter Apochens
    [**SimpleLoopUnswitch-L1248**](https://github.com/llvm/llvm-project/blob/298e292a76289d93f7c1a80c26e354830c6080e4/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp#L1248C1-L1253C52)

```cpp
-> auto *MergePN =
          PHINode::Create(I.getType(), /*NumReservedValues*/ 2, ".us-phi");
 MergePN->insertBefore(MergeBB->getFirstInsertionPt());
 I.replaceAllUsesWith(MergePN);
      MergePN->addIncoming(&I, ExitBB);
 MergePN->addIncoming(&ClonedI, ClonedExitBB);
```

[**SimpleLoopUnswitch-L1310**](https://github.com/llvm/llvm-project/blob/298e292a76289d93f7c1a80c26e354830c6080e4/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp#L1310)

```cpp
 ClonedTerminator->eraseFromParent();
-> BranchInst::Create(ClonedSuccBB, ClonedParentBB);
```

[**SimpleLoopUnswitch-L2339**](https://github.com/llvm/llvm-project/blob/298e292a76289d93f7c1a80c26e354830c6080e4/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp#L2339)

This instruction `TI` is moved out of the loop (i.e., the hoisted conditional instruction in LoopUnswitch) without dropping its debug location.

```cpp
    TI.moveBefore(*SplitBB, SplitBB->end());
```

[**SimpleLoopUnswitch-L2352**](https://github.com/llvm/llvm-project/blob/298e292a76289d93f7c1a80c26e354830c6080e4/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp#L2352)

```cpp
 Value *Cond = skipTrivialSelect(BI->getCondition());
      if (InsertFreeze)
->      Cond = new FreezeInst(Cond, Cond->getName() + ".fr", BI->getIterator());
 BI->setCondition(Cond);
```

[**SimpleLoopUnswitch-L2440**](https://github.com/llvm/llvm-project/blob/298e292a76289d93f7c1a80c26e354830c6080e4/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp#L2440)

```cpp
 // After MSSAU update, remove the cloned terminator instruction NewTI.
 ParentBB->getTerminator()->eraseFromParent();

    // Create a new unconditional branch to the continuing block (as opposed to
    // the one cloned).
->  BranchInst::Create(RetainedSuccBB, ParentBB);
```

[**SimpleLoopUnswitch-L2709**](https://github.com/llvm/llvm-project/blob/298e292a76289d93f7c1a80c26e354830c6080e4/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp#L2709)

```cpp
-> PHINode *Phi =
        PHINode::Create(SI->getType(), 2, "unswitched.select", SI->getIterator());
 Phi->addIncoming(SI->getTrueValue(), ThenBB);
 Phi->addIncoming(SI->getFalseValue(), HeadBB);
 SI->replaceAllUsesWith(Phi);
 SI->eraseFromParent();
```

godbolt: https://godbolt.org/z/dGGs89eKT (Note that the hoisted br instruction with `!dbg !8` in `%entry` is corresponding to L2339 and other instructions without `!dbg` are corresponding to other Lxxx)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to