This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fix worklist management when removing guard intrinsic
ClosedPublic

Authored by nikic on Jan 11 2020, 9:34 AM.

Details

Summary

When multiple guard intrinsics are merged into one, currently the result of eraseInstFromFunction() is returned -- however, this should only be done if the current instruction is being removed. In this case we're removing a different instruction and should instead report that the current one has been modified by returning it.

For this test case, this reduces the number of instcombine iterations from 5 to 2 (the minimum possible).

Diff Detail

Event Timeline

nikic created this revision.Jan 11 2020, 9:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 11 2020, 9:34 AM
lebedev.ri resigned from this revision.Jan 13 2020, 1:52 AM

Sorry, i don't know what @llvm.experimental.guard() is.

spatel accepted this revision.Jan 14 2020, 12:25 PM

I don't know anything about experimental.guard either, but the change LGTM based on similar transforms.
Instcombine's visit* contract is:

// Visitation implementation - Implement instruction combining for different
// instruction types.  The semantics are as follows:
// Return Value:
//    null        - No change was made
//     I          - Change was made, I is still valid, I may be dead though
//   otherwise    - Change was made, replace I with returned instruction
This revision is now accepted and ready to land.Jan 14 2020, 12:25 PM
This revision was automatically updated to reflect the committed changes.