This is an archive of the discontinued LLVM Phabricator instance.

Disallow shift operations in debug expressions spanning multiple registers
ClosedPublic

Authored by StephenTozer on Nov 14 2019, 9:00 AM.

Details

Summary

Split from another patch, which this patch should precede: https://reviews.llvm.org/D61184

This patch fixes an issue which was exposed in the initial merge of the patch in the review linked above, in which:

  • Debug expressions containing shift operators could be split across multiple registers during instruction selection, resulting in incorrect debug information as the shifted bits will not carry across these registers.
  • When a debug expression is split into fragments during instruction selection and the expression cannot be made into a valid fragment expression then no DBG_VALUE instruction is produced; this patch correctly adds an undef DBG_VALUE instruction, preventing the debug info from becoming outdated.

Diff Detail

Event Timeline

StephenTozer created this revision.Nov 14 2019, 9:00 AM
vsk added inline comments.Nov 14 2019, 10:58 AM
llvm/test/CodeGen/ARM/debuginfo-split-carryexpr.ll
18

It's strange that the DBG_VALUE MIs here are in reverse order (compared to IR). Perhaps that's worth filing a follow-up bug about?

23

Mind adding coverage for shr/shl?

aprantl added inline comments.Nov 14 2019, 11:22 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
5561

This is a good change.

llvm/lib/IR/DebugInfoMetadata.cpp
1153 ↗(On Diff #229310)

This is good too, but should land in a separate, preparatory patch, tested by a unit test in IR/MetadataTest.cpp.

djtodoro added inline comments.Nov 15 2019, 12:03 AM
llvm/test/CodeGen/ARM/debuginfo-split-carryexpr.ll
33

It is enough only producer: "clang version 10.0.0".

39

Same as above. (It is enough only producer: "clang version 10.0.0".)

41

test.cpp, /tmp

Orlando added inline comments.
llvm/test/CodeGen/ARM/debuginfo-split-carryexpr.ll
18

I reckon this is LiveDebugVariables. It should preserve order of DBG_VALUES for (all fragments of ) a particular source variable but not between variables. However, at the moment it doesn't correctly group the DBG_VALUES - DIExpression is used as part of the identity (so a different complex expression referring to the same or overlapping variable fragments is considered a different source variable) . My patch [0] fixes the grouping so only the inconsequential reordering of unrelated DBG_VALUES will happen.

[0] https://reviews.llvm.org/D70121

Rebased off of merged parent, trimmed unnecessary/confusing test metadata.

djtodoro accepted this revision.Nov 28 2019, 1:48 AM

LGTM. Thanks for doing this!

Please wait for someone from debug-info project to approve it as well.

This revision is now accepted and ready to land.Nov 28 2019, 1:48 AM
aprantl accepted this revision.Dec 2 2019, 11:27 AM
This revision was automatically updated to reflect the committed changes.