[PATCH] D74517: [Local] Do not move around dbg.declares during replaceDbgDeclare

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 11:01:43 PST 2020


vsk added a comment.

In D74517#1873432 <https://reviews.llvm.org/D74517#1873432>, @eugenis wrote:

> I think the point of moving dbg.declare was to make sure it is dominated by the new expression. Ex. in ASan we place it immediately after the base pointer definition. 
>  If you are sure this condition holds in all call sites, then LGTM.


@eugenis IIUC, post-ASan, each dbg.declare(<alloca>) should be dominated by <alloca>, even if none of the dbg.declares are hoisted. I added the following assert to test this while building a stage2 llc:

     // Replace Alloca instructions with base+offset.
  +  DominatorTree DT(F);
     for (const auto &Desc : SVD) {
       AllocaInst *AI = Desc.AI;
  +    assert(DT.dominates(cast<Instruction>(LocalStackBaseAllocaPtr), AI));
       replaceDbgDeclare(AI, LocalStackBaseAllocaPtr, DIB, DIExprFlags,
                         Desc.Offset);

If the input IR has no debug use-before-def, the post-ASan IR should look good as well, because ASan either does not move `AI` or it hoists it (from `StaticAllocasToMoveUp`). Does that answer your question?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74517/new/

https://reviews.llvm.org/D74517





More information about the llvm-commits mailing list