This is an archive of the discontinued LLVM Phabricator instance.

[LAA] Avoid adding pointers to the checks if they are not needed.
ClosedPublic

Authored by fhahn on Jul 26 2020, 2:57 PM.

Details

Summary

Currently we skip alias sets with only reads or a single write and no
reads, but still add the pointers to the list of pointers in RtCheck.

This can lead to cases where we try to access a pointer that does not
exist when grouping checks. In most cases, the way we access
PositionMap masked that, as the value would default to index 0.

But in the example in PR46854 it causes a crash.

This patch updates the logic to avoid adding pointers for alias sets
that do not need any checks. It makes things slightly more verbose, by
first checking the numbers of reads/writes and bailing out early if we don't
need checks for the alias set.

I think this makes the logic a bit simpler to follow.

Diff Detail

Event Timeline

fhahn created this revision.Jul 26 2020, 2:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2020, 2:57 PM
Herald added a subscriber: hiraditya. · View Herald Transcript

Instead of accumulating in AccessInfos, couldn't we just reiterate the alias set (if we didn't bail out)?

Instead of accumulating in AccessInfos, couldn't we just reiterate the alias set (if we didn't bail out)?

Yes, I think either approach is fine. The current way avoids a few repeated lookups, but in the grand scheme of things I don't think it makes a big difference.

Instead of accumulating in AccessInfos, couldn't we just reiterate the alias set (if we didn't bail out)?

Yes, I think either approach is fine. The current way avoids a few repeated lookups, but in the grand scheme of things I don't think it makes a big difference.

You mean in Accesses.. Well, since the iteration in an AliasSet is deterministic we could also only save the bools in a BitVector and both save memory and not do lookups. But never mind if you consider it overthinking / nitpicking.

Apart from that, now that I'm seeing it again, in LAA, we probably want to move a lot of vectors out of loops and just reset() them.

anemet accepted this revision.Jul 29 2020, 2:40 PM

Looks reasonable to me.

This revision is now accepted and ready to land.Jul 29 2020, 2:40 PM
fhahn added a comment.Jul 30 2020, 7:13 AM

Thanks for taking a look @baziotis & @anemet !

Instead of accumulating in AccessInfos, couldn't we just reiterate the alias set (if we didn't bail out)?

Yes, I think either approach is fine. The current way avoids a few repeated lookups, but in the grand scheme of things I don't think it makes a big difference.

You mean in Accesses.. Well, since the iteration in an AliasSet is deterministic we could also only save the bools in a BitVector and both save memory and not do lookups. But never mind if you consider it overthinking / nitpicking.

Yeah, this code is very unlikely to be performance critical, so IMO we should try to make the code as straight-forward as possible. I think it would be good to stick with the version in the patch initially and potentially do follow-on improvements as follow-up patches.

Thanks for taking a look @baziotis & @anemet !

Instead of accumulating in AccessInfos, couldn't we just reiterate the alias set (if we didn't bail out)?

Yes, I think either approach is fine. The current way avoids a few repeated lookups, but in the grand scheme of things I don't think it makes a big difference.

You mean in Accesses.. Well, since the iteration in an AliasSet is deterministic we could also only save the bools in a BitVector and both save memory and not do lookups. But never mind if you consider it overthinking / nitpicking.

Yeah, this code is very unlikely to be performance critical, so IMO we should try to make the code as straight-forward as possible. I think it would be good to stick with the version in the patch initially and potentially do follow-on improvements as follow-up patches.

Of course, yes.

This revision was landed with ongoing or failed builds.Jul 30 2020, 11:21 AM
This revision was automatically updated to reflect the committed changes.