This is an archive of the discontinued LLVM Phabricator instance.

[test][AliasAnalysis] Add some baseline tests in preparation for getModRefInfoMask().
ClosedPublic

Authored by pcwalton on Oct 28 2022, 3:16 PM.

Details

Summary

This commit adds some tests in preparation for D136659, which allows alias
analysis to treat locally-invariant memory pointed to by readonly noalias
pointers the same as globally-invariant memory in some cases. The existing
behavior for these tests is marked as expected and will be changed when that
diff lands.

Diff Detail

Event Timeline

pcwalton created this revision.Oct 28 2022, 3:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 28 2022, 3:16 PM
pcwalton requested review of this revision.Oct 28 2022, 3:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 28 2022, 3:16 PM

I'm not sure if this needs review or not, but I thought I'd ask to be safe.

nikic added inline comments.Oct 29 2022, 1:44 AM
llvm/test/Analysis/BasicAA/constant-memory.ll
45

While here, I think we may also want to add variations with readnone and writeonly.

I initially thought we might be able to return NoModRef/Ref/Mod depending on readnone/readonly/writeonly, but I think this is not actually the case. For noalias readnone, reads of the object through other pointers are still legal. For noalias writeonly, reads of the object through other pointers are also legal, as long as this pointer is not actually written.

As such, Ref for readnone/readonly and ModRef for writeonly are the best we can do.

llvm/test/Transforms/InstCombine/memcpy-from-global.ll
344

Drop attributes that are not needed for the transform, e.g. nocapture, noundef are probably not relevant here.

We can also give this a more meaningful name, say memcpy_from_readonly_noalias.

352

Attributes on the memcpy are likely not needed here and a bit confusing in this case -- you're using dereferenceable(12), but the actual size is 124. (This is legal, just odd.)

353

You can probably reuse the @bar() function from above here? And likely only need the call readonly attribute, not the parameter attributes.

355

Can complement this with the same test, but without the noalias again.

pcwalton updated this revision to Diff 471765.Oct 29 2022, 11:27 AM

Addressed review comments.

pcwalton marked 5 inline comments as done.Oct 29 2022, 11:33 AM
nikic accepted this revision.Oct 29 2022, 12:27 PM

LGTM

This revision is now accepted and ready to land.Oct 29 2022, 12:27 PM