[PATCH] D55396: [DebugInfo] Make sure CodeGenPrepare does not drop MD references to locals.

Wolfgang Pieb via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 6 15:58:08 PST 2018


wolfgangp created this revision.
wolfgangp added reviewers: aprantl, dexonsmith.

This addresses PR39845 <https://bugs.llvm.org/show_bug.cgi?id=39845>.

CGP (CodeGenPrepare) performs a variety of optimizations using a transactional approach, i.e. it makes changes to the instructions and rolls these changes back when it finds that they don't improve the code. In particular, the undoing involves the reversal or RAUWs, which involves the tracking of uses of a value along with replacing these uses with the original value.

Currently Metadata uses are not tracked, however. In particular, any references from dbg.value instructions to locals that were RAUWed by the initial optimization attempt are not restored, negatively affecting debug info.

This patch tries to at least partially solve this problem by performing a reverse RAUW to undo the substitution, but this is obviously only correct when the replacement value was not referenced by Metadata at the time of the first replacement. 
The complete solution would require keeping track of existing MD-uses of the replacement value, something I didn't want to attempt without consultation of someone with more in-depth knowledge of Metadata handling. However, the patch should improve a lot of cases, as many values created by CGP's optimizations are newly created.

Any suggestions on how to handle this better are welcome.


https://reviews.llvm.org/D55396

Files:
  lib/CodeGen/CodeGenPrepare.cpp
  test/DebugInfo/Generic/codegenprep-value.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55396.177060.patch
Type: text/x-patch
Size: 4972 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181206/edbb6d8c/attachment.bin>


More information about the llvm-commits mailing list