Skip to content

Commit

Permalink
[DebugInfo] Correction for an assert in DIExpression::createFragmentE…
Browse files Browse the repository at this point in the history
…xpression

Summary:
When we create a fragment expression, and there already is an
old fragment expression, we assert that the new fragment is
within the range for the old fragment.

If for example the old fragment expression says that we
describe bit 10-16 of a variable (Offset=10, Size=6),
and we now want to create a new fragment expression only
describing bit 3-6 of the original value, then the resulting
fragment expression should have Offset=13, Size=3.

The assert is supposed to catch if the resulting fragment
expression is outside the range for the old fragment. However,
it used to verify that the Offset+Size of the new fragment was
smaller or equal than Offset+Size for the old fragment. What
we really want to check is that Offset+Size of the new fragment
is smaller than the Size of the old fragment.

Reviewers: aprantl, vsk

Reviewed By: aprantl

Subscribers: davide, llvm-commits, JDevlieghere

Differential Revision: https://reviews.llvm.org/D46391

llvm-svn: 331465
  • Loading branch information
bjope committed May 3, 2018
1 parent 304877e commit 5479ad2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions llvm/lib/IR/DebugInfoMetadata.cpp
Expand Up @@ -830,9 +830,9 @@ Optional<DIExpression *> DIExpression::createFragmentExpression(
case dwarf::DW_OP_LLVM_fragment: {
// Make the new offset point into the existing fragment.
uint64_t FragmentOffsetInBits = Op.getArg(0);
// Op.getArg(0) is FragmentOffsetInBits.
// Op.getArg(1) is FragmentSizeInBits.
assert((OffsetInBits + SizeInBits <= Op.getArg(0) + Op.getArg(1)) &&
uint64_t FragmentSizeInBits = Op.getArg(1);
(void)FragmentSizeInBits;
assert((OffsetInBits + SizeInBits <= FragmentSizeInBits) &&
"new fragment outside of original fragment");
OffsetInBits += FragmentOffsetInBits;
continue;
Expand Down

0 comments on commit 5479ad2

Please sign in to comment.