This is an archive of the discontinued LLVM Phabricator instance.

[EarlyCSE] Common gc.relocate calls.
ClosedPublic

Authored by dantrushin on May 22 2020, 9:10 AM.

Details

Summary

gc.relocate intrinsic is special in that its second and third operands
are not real values, but indices into relocate's parent statepoint list
of GC pointers.
To be CSE'd, they need special handling in isEqual() and getHashCode().

Diff Detail

Event Timeline

dantrushin created this revision.May 22 2020, 9:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2020, 9:10 AM

Remove debug leftover

Just to be clear, if the indices are the same, gc.relocates would already be removed right? i.e. the thing you're trying to solve is that the standpoint can have two operands which are the same value and thus two gc.relocates which are equivalent but not textually identical? Just want to make sure I understand the problem properly.

Another solution to the same problem would be to canonicalize the statepoint in an instcombine rule to avoid duplicate operands in the gc operand section. Have you explored that possibility?

Just to be clear, if the indices are the same, gc.relocates would already be removed right? i.e. the thing you're trying to solve is that the standpoint can have two operands which are the same value and thus two gc.relocates which are equivalent but not textually identical? Just want to make sure I understand the problem properly.

That's right.

Another solution to the same problem would be to canonicalize the statepoint in an instcombine rule to avoid duplicate operands in the gc operand section. Have you explored that possibility?

Well, CSE solution looked to me more elegant - all I need is adjust hash and the rest will be done automatically.
While in instcombine after statepoint operand uniqueing I would have to visit all relocates and update them. Second logical step would be to implement gc.relocate CSE'ing there which I didn't want to do.
And operand uniqueing itself is sort of CSE, so I would need to implement it in InstCombine using some sort of Set etc.

Also, operands might be equivalent, but not textually identical, which InstCombine cannot handle.
(I'm not sure if LLVM's CSE can. This sounds as value numbering).

reames accepted this revision.May 29 2020, 12:12 PM

LGTM

This revision is now accepted and ready to land.May 29 2020, 12:12 PM
This revision was automatically updated to reflect the committed changes.