[PATCH] D136993: [test][AliasAnalysis] Add some baseline tests in preparation for getModRefInfoMask().
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 29 01:44:20 PDT 2022
nikic added inline comments.
================
Comment at: llvm/test/Analysis/BasicAA/constant-memory.ll:45
+ ret void
+}
+
----------------
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.
================
Comment at: llvm/test/Transforms/InstCombine/memcpy-from-global.ll:344
+; Tests that we can't eliminate allocas copied from readonly noalias pointers yet.
+define void @test12(ptr nocapture noundef readonly noalias align 8 dereferenceable(124) %arg) {
+; CHECK-LABEL: @test12(
----------------
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`.
================
Comment at: llvm/test/Transforms/InstCombine/memcpy-from-global.ll:352
+ %alloca = alloca %T, align 8
+ call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull dereferenceable(12) %alloca, ptr noundef nonnull dereferenceable(12) %arg, i64 124, i1 false)
+ call void @boo(ptr readonly noalias noundef nonnull nocapture align 8 %alloca) readonly
----------------
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.)
================
Comment at: llvm/test/Transforms/InstCombine/memcpy-from-global.ll:353
+ call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull dereferenceable(12) %alloca, ptr noundef nonnull dereferenceable(12) %arg, i64 124, i1 false)
+ call void @boo(ptr readonly noalias noundef nonnull nocapture align 8 %alloca) readonly
+ ret void
----------------
You can probably reuse the `@bar()` function from above here? And likely only need the call `readonly` attribute, not the parameter attributes.
================
Comment at: llvm/test/Transforms/InstCombine/memcpy-from-global.ll:355
+ ret void
+}
+
----------------
Can complement this with the same test, but without the `noalias` again.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136993/new/
https://reviews.llvm.org/D136993
More information about the llvm-commits
mailing list