This is an archive of the discontinued LLVM Phabricator instance.

[RewriteStatepointsForGC] Extend base pointer inference to handle insertelement
ClosedPublic

Authored by reames on Sep 2 2015, 6:17 PM.

Details

Summary

This change is simply enhancing the existing inference algorithm to handle insertelement instructions by conservatively inserting a new instruction to propagate the vector of associated base pointers. In the process, I'm ripping out the peephole optimizations which mostly helped cover the fact this hadn't been done.

Note that most of the newly inserted nodes will be nearly immediately removed by the post insertion optimization pass introduced in 246718. Arguably, we should be trying harder to avoid the malloc traffic here, but I'd rather get the code correct, then worry about compile time.

Unlike previous extensions of the algorithm to handle more case, I discovered the existing code was causing miscompiles in some cases. In particular, we had an implicit assumption that the peephole covered *all* insert element instructions, so if we had a value directly based on a insert element the peephole didn't cover, we proceeded as if it were a base anyways. Not good. I believe we had the same issue with shufflevector which is why I adjusted the predicate for them as well.

Note: As posted for review, this patch will show non-deterministic test failures. This isn't actually a problem with the newly added code. The new code just exposes another issue with 246718 which I'm going to fix separately.

Diff Detail

Repository
rL LLVM

Event Timeline

reames updated this revision to Diff 33897.Sep 2 2015, 6:17 PM
reames retitled this revision from to [RewriteStatepointsForGC] Extend base pointer inference to handle insertelement.
reames updated this object.
reames added a reviewer: sanjoy.
reames edited subscribers, added: llvm-commits; removed: sanjoy.Sep 2 2015, 6:17 PM
sanjoy accepted this revision.Sep 7 2015, 5:26 PM
sanjoy edited edge metadata.

lgtm with comments inline:

lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
292 ↗(On Diff #33897)

Please update the comment, now that there is no Index.

860 ↗(On Diff #33897)

Braces unnecessary here.

Minor style nit: I'd put the entire implication inside the assert, like assert(!isa<InsertEle>() || State.isConflict()).

1006 ↗(On Diff #33897)

These blocks of code should be pulled into a common lambda or a static helper. But that's okay to do post-commit.

This revision is now accepted and ready to land.Sep 7 2015, 5:26 PM
This revision was automatically updated to reflect the committed changes.