[PATCH] D45975: [DebugInfo] Invalidate debug info in ReassociatePass::RewriteExprTree

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 23 11:13:02 PDT 2018


bjope created this revision.
bjope added reviewers: dblaikie, aprantl, dexonsmith.
bjope added a project: debug-info.
Herald added a subscriber: JDevlieghere.

When Reassociate is rewriting an expression tree it may
reuse old binary expression nodes, for new expressions.
Whenever an expression node is reused, but with a non-trivial
change in the result, we need to invalidate any debug info
that is associated with the node.

If for example rewriting

  x = mul a, b
  y = mul c, x

into

  x = mul c, b
  y = mul a, x

we still get the same result for 'y', but 'x' is a new expression.
All debug info referring to 'x' must be invalidated (marked as
optimized out) since we no longer calculate the expected value.

As a side-effect this patch avoid (at least some) problems where
reassociate could end up creating IR with debug-use before def.
Earlier the dbg.value nodes where left untouched in the IR, while
the reused binary nodes where sinked to just before the root node
of the rewritten expression tree. See PR27273 for more info about
such problems.


Repository:
  rL LLVM

https://reviews.llvm.org/D45975

Files:
  lib/Transforms/Scalar/Reassociate.cpp
  test/Transforms/Reassociate/reassociate_dbgvalue_discard.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45975.143603.patch
Type: text/x-patch
Size: 5760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180423/e601b3de/attachment.bin>


More information about the llvm-commits mailing list