Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ScopedNoAliasAA] Should ScopedNoAliasAA be more conservative in getting ModRef? #70158

Closed
DianQK opened this issue Oct 25, 2023 · 1 comment
Closed
Assignees
Labels

Comments

@DianQK
Copy link
Member

DianQK commented Oct 25, 2023

This IR is reduced from rust-lang/rust#116976.

declare void @use(i64)

define i64 @foo(ptr noalias nocapture noundef align 8 dereferenceable(24) %p) {
  %p1 = getelementptr inbounds i8, ptr %p, i64 16
  %v1 = load i64, ptr %p1, align 8
  call void @use(i64 %v1)
  %p2 = getelementptr inbounds i8, ptr %p, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %p2, i8 0, i64 16, i1 false), !alias.scope !0
  %v2 = load i64, ptr %p1, align 8, !noalias !0
  ret i64 %v2
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!0 = !{!1}
!1 = distinct !{!1, !2}
!2 = distinct !{!2}

godbolt: https://llvm.godbolt.org/z/7sTrhYdMo

Currently, GVN replaces %v2 with %v1.
Maybe I'm missing something here. Other passes may have provided incorrect alias information.

From the LLVM Alias Analysis Infrastructure, my understanding is that the alias method returns alias when two memory objects alias each other. And the getModRefInfo returns ModRef when an/any alias exists.

@DianQK
Copy link
Member Author

DianQK commented Oct 27, 2023

This is not a source of error.

@DianQK DianQK closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
@DianQK DianQK added the invalid Resolved as invalid, i.e. not a bug label Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant