Skip to content

[Inline] Only consider provenance captures for scoped alias metadata #138540

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

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion llvm/lib/Transforms/Utils/InlineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,9 @@ static void AddAliasScopeMetadata(CallBase &CB, ValueToValueMapTy &VMap,
// nocapture only guarantees that no copies outlive the function, not
// that the value cannot be locally captured.
if (!RequiresNoCaptureBefore ||
!PointerMayBeCapturedBefore(A, /* ReturnCaptures */ false, I, &DT))
!capturesAnything(PointerMayBeCapturedBefore(
A, /*ReturnCaptures=*/false, I, &DT, /*IncludeI=*/false,
CaptureComponents::Provenance)))
NoAliases.push_back(NewScopes[A]);
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/Inline/noalias-escape-source.ll
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ define void @test_addr_only_capture(ptr %p) {
; CHECK-SAME: ptr [[P:%.*]]) {
; CHECK-NEXT: call void @llvm.experimental.noalias.scope.decl(metadata [[META6:![0-9]+]])
; CHECK-NEXT: call void @capture(ptr captures(address) [[P]])
; CHECK-NEXT: [[P2_I:%.*]] = call ptr @get_ptr()
; CHECK-NEXT: [[P2_I:%.*]] = call ptr @get_ptr(), !noalias [[META6]]
; CHECK-NEXT: [[V_I:%.*]] = load i32, ptr [[P]], align 4, !alias.scope [[META6]]
; CHECK-NEXT: store i32 [[V_I]], ptr [[P2_I]], align 4
; CHECK-NEXT: store i32 [[V_I]], ptr [[P2_I]], align 4, !noalias [[META6]]
; CHECK-NEXT: ret void
;
call void @callee_addr_only_capture(ptr %p)
Expand Down