This is an archive of the discontinued LLVM Phabricator instance.

[RewriteStatepointsForGC] Fix debug assertion during derivable pointer rematerialization
ClosedPublic

Authored by igor-laevsky on May 20 2015, 9:47 AM.

Details

Summary

Correct assertion would be that there is no other uses from chain we are currently cloning. It is ok to have other uses of values not from this chain.

Diff Detail

Repository
rL LLVM

Event Timeline

igor-laevsky retitled this revision from to [RewriteStatepointsForGC] Fix debug assertion during derivable pointer rematerialization.
igor-laevsky updated this object.
igor-laevsky edited the test plan for this revision. (Show Details)
igor-laevsky added a reviewer: sanjoy.
igor-laevsky set the repository for this revision to rL LLVM.
igor-laevsky added a subscriber: Unknown Object (MLST).
sanjoy accepted this revision.May 20 2015, 11:47 AM
sanjoy edited edge metadata.

LGTM with comments.

lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
1947 ↗(On Diff #26155)

IIUC, the invariant that is interesting to check here is: before the replaceUsesOfWith call, ClonedValue uses exactly one of the values in ChainToBase and that value is LastValue. Is there a way you can rewrite the assert to check that instead? Basically, before ClonedValue->replaceUsesOfWith, have something like:

for (auto OpValue : ...) {
  if(find(ChainToBase.begin(), .end(), OpValue))
    assert(OpValue == LastValue);
This revision is now accepted and ready to land.May 20 2015, 11:47 AM
sanjoy added inline comments.May 20 2015, 11:52 AM
lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
1947 ↗(On Diff #26155)

Actually a slightly stronger invariant can be enforced by:

bool FoundLastValue = false;
for (auto OpValue : ...) {
  if(find(ChainToBase.begin(), .end(), OpValue)) {
    assert(OpValue == LastValue);
    FoundLastValue = true;
  }
assert(FoundLastValue);
This revision was automatically updated to reflect the committed changes.