[PATCH] D53130: [DebugInfo][LCSSA] Rewrite pre-existing debug values outside loop

David Stenberg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 11 02:10:38 PDT 2018


dstenb created this revision.
dstenb added reviewers: mattd, aprantl, vsk, probinson.
Herald added subscribers: llvm-commits, JDevlieghere.

Extend LCSSA so that debug values outside loops are rewritten to
use the PHI nodes that the pass creates.

This fixes PR39019. In that case, we ran LCSSA on a loop that
was later on vectorized, which left us with something like this:

  for.cond.cleanup:
    %add.lcssa = phi i32 [ %add, %for.body ], [ %34, %middle.block ]
    call void @llvm.dbg.value(metadata i32 %add,
    ret i32 %add.lcssa
  
  for.body:
    %add =
    [...]
    br i1 %exitcond, label %for.cond.cleanup, label %for.body

which later resulted in the debug.value becoming undef when
removing the scalar loop (and the location would have probably
been wrong for the vectorized case otherwise).

As we now may need to query the AvailableVals cache more than
once for a basic block, FindAvailableVals() in SSAUpdaterImpl is
changed so that it updates the cache for blocks that we do not
create a PHI node for, regardless of the block's number of
predecessors. The debug value in the attached IR reproducer
would not be properly rewritten without this.

Debug values residing in blocks where we have not inserted any
PHI nodes are currently left as-is by this patch. I'm not sure
what should be done with those uses.


Repository:
  rL LLVM

https://reviews.llvm.org/D53130

Files:
  include/llvm/Transforms/Utils/SSAUpdater.h
  include/llvm/Transforms/Utils/SSAUpdaterImpl.h
  lib/Transforms/Utils/LCSSA.cpp
  lib/Transforms/Utils/SSAUpdater.cpp
  test/Transforms/LCSSA/rewrite-existing-dbg-values.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53130.169172.patch
Type: text/x-patch
Size: 6623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181011/46c3c0fa/attachment.bin>


More information about the llvm-commits mailing list