This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Improve handling of dangling debug info
ClosedPublic

Authored by bjope on Mar 11 2018, 1:32 PM.

Details

Summary
  1. Make sure to discard dangling debug info if the variable (or

variable fragment) is mapped to something new before we had a
chance to resolve the dangling debug info.

  1. When resolving debug info, make sure to bump the associated

SDNodeOrder to ensure that the DBG_VALUE is emitted after the
instruction that defines the value used in the DBG_VALUE.
This will avoid a debug-use before def scenario as seen in
https://bugs.llvm.org/show_bug.cgi?id=36417.

The new test case, test/DebugInfo/X86/sdag-dangling-dbgvalue.ll,
show some other limitations in how dangling debug info is
handled in the SelectionDAG. Since we currently only support
having one dangling dbg.value per Value, we will end up dropping
debug info when there are more than one variable that is described
by the same "dangling value".

Diff Detail

Event Timeline

bjope created this revision.Mar 11 2018, 1:32 PM
bjope edited the summary of this revision. (Show Details)
aprantl accepted this revision.Mar 12 2018, 9:02 AM

Thanks! I have a few comments inline but otherwise this LGTM.

include/llvm/IR/DebugInfoMetadata.h
2420

Could you unify this with DebugHandlerBase::fragmentsOverlap() and remove one of the two implementations?

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
1082

what is DB?

1083

I know that this file isn't following the LLVM coding style, but for a new function I would still prefer the comment in the header file.

1106–1107

while you are in here, could you replace this with an early exit?

This revision is now accepted and ready to land.Mar 12 2018, 9:02 AM
bjope updated this revision to Diff 138051.Mar 12 2018, 10:27 AM

Thanks Adrian!
Updated the patch according to suggestions:

  • Moved doxygen comments for dropDanglingDebugInfo
  • Early exit in resolveDanglingDebugInfo
  • Moved fragmentCmp/fragmentsOverlap from DebugHandlerBase to DIExpression
aprantl accepted this revision.Mar 12 2018, 10:49 AM

You might want to split out the fragment compare refactoring into a separate commit, but LGTM.

This revision was automatically updated to reflect the committed changes.
vsk added a subscriber: gramanas.Mar 13 2018, 2:44 PM