Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InlineFunction] Only update noalias scopes once for an instruction.
Inlining sometimes maps different instructions to be inlined onto the same instruction. We must ensure to only remap the noalias scopes once. Otherwise the scope might disappear (at best). This patch ensures that we only replace scopes for which the mapping is known. This approach is preferred over tracking which instructions we already handled in a SmallPtrSet, as that one will need more memory. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D95862
- Loading branch information
1 parent
3e78061
commit 50c523a
Showing
2 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature | ||
; RUN: opt -inline -S < %s | FileCheck %s | ||
|
||
define void @caller(i8* %ptr) { | ||
; CHECK-LABEL: define {{[^@]+}}@caller | ||
; CHECK-SAME: (i8* [[PTR:%.*]]) { | ||
; CHECK-NEXT: [[I_I:%.*]] = load i8, i8* [[PTR]], align 1, !alias.scope !0 | ||
; CHECK-NEXT: ret void | ||
; | ||
call void @callee(i8* %ptr) | ||
ret void | ||
} | ||
|
||
define void @callee(i8* %ptr) { | ||
; CHECK-LABEL: define {{[^@]+}}@callee | ||
; CHECK-SAME: (i8* [[PTR:%.*]]) { | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[I:%.*]] = load i8, i8* [[PTR]], align 1, !alias.scope !3 | ||
; CHECK-NEXT: br label [[DUMMY:%.*]] | ||
; CHECK: dummy: | ||
; CHECK-NEXT: [[I_COPY:%.*]] = phi i8 [ [[I]], [[ENTRY:%.*]] ] | ||
; CHECK-NEXT: ret void | ||
; | ||
entry: | ||
%i = load i8, i8* %ptr, !alias.scope !0 | ||
br label %dummy | ||
|
||
dummy: | ||
%i.copy = phi i8 [ %i, %entry ] | ||
ret void | ||
} | ||
|
||
!0 = !{!1} | ||
!1 = distinct !{!1, !2} | ||
!2 = distinct !{!2} |