This is an archive of the discontinued LLVM Phabricator instance.

Improve ConvertDebugDeclareToDebugValue
ClosedPublic

Authored by bjope on Jun 25 2018, 6:59 AM.

Details

Summary

This is a follow-up to r334830 and r335031.

In the valueCoversEntireFragment check we now also handle
the situation when there is a variable length array (VLA)
involved, and the length of the array has been reduced to
a constant.

The ConvertDebugDeclareToDebugValue functions that are related
to PHI nodes and load instructions now avoid inserting dbg.value
intrinsics when the value does not, for certain, cover the
variable/fragment that should be described.
In r334830 we assumed that the value always covered the entire
var/fragment and we had assertions in the code to show that
assumption. However, those asserts failed when compiling code
with VLAs, so we removed the asserts in r335031. Now when we
know that the valueCoversEntireFragment check can fail also for
PHI/Load instructions we avoid to insert the faulty dbg.value
intrinsic in such situations. Compared to the Store instruction
scenario we simply drop the dbg.value here (as the variable does
not change its value due to PHI/Load, so an earlier dbg.value
describing the variable should still be valid).

Diff Detail

Repository
rL LLVM

Event Timeline

bjope created this revision.Jun 25 2018, 6:59 AM
aprantl added inline comments.Jun 25 2018, 8:18 AM
include/llvm/IR/Instructions.h
103 ↗(On Diff #152685)

We generally try to move away from special values. Would it make sense to return an Optional<uint64_t> here?

test/Transforms/Mem2Reg/debug-alloca-vla-1.ll
3 ↗(On Diff #152685)

Can you add a comment explaining what is being tested here?

test/Transforms/Mem2Reg/debug-alloca-vla-2.ll
20 ↗(On Diff #152685)

and here?

bjope updated this revision to Diff 152708.Jun 25 2018, 9:32 AM

Update after review comments:

  • Use Optional in AllocaInst::getAllocationSizeInBits.
  • Add comments describing the added test cases.
aprantl accepted this revision.Jun 25 2018, 10:16 AM
This revision is now accepted and ready to land.Jun 25 2018, 10:16 AM
This revision was automatically updated to reflect the committed changes.