Skip to content

[DebugInfo][SimpleLoopUnswitch] Missing debug location updates (Part 1) #97559

@Apochens

Description

@Apochens

SimpleLoopUnswitch-L1248

->    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

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

SimpleLoopUnswitch-L2339

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

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

SimpleLoopUnswitch-L2352

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

SimpleLoopUnswitch-L2440

    // 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

->  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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions