-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
[Inliner] noalias metadata incorrectly propagated to caller instructions #49614
Comments
assigned to @dobbelaj-snps |
I believe this shows the same issue during metadata remapping: declare { i64* } @opaque_callee() define { i64* } @self_caller(i1 %c, i64* %a) { if: else: !0 = !{#0, !"domain"} opt -inline results in: declare { i64* } @opaque_callee() define { i64* } @self_caller(i1 %c, i64* %a) { if: ; preds = %0 else: ; preds = %0 !0 = !{#1} @opaque_callee() here should have retained metadata !3, rather than being assigned !0. This case is a bit trickier to produce, because we only remap metadata that is used in the callee, so this only happens if the caller and the callee are the same (or share metadata, but I think that's rather ill-defined). |
Candidate patch: https://reviews.llvm.org/D102110 |
Fixed by aa9b02a on main. Keeping this issue open to track 12.0.1 backport. |
Hi Jeroen, What is your opinion on backporting this? https://reviews.llvm.org/rGaa9b02ac75350a6c7c949dd24d5c6a931be26ff9 |
After this fix, I also discovered that the OpenMP tests are failing on both Arch Linux 32 and i686 OpenSUSE Tumbleweed. Reported as Bug 50303. |
Hi Tom, I do think we should backport this. |
Merged: 4eb7b15 |
Extended Description
declare { i64 } @opaque_callee()
define { i64 } @callee(i64 %x) {
%res = insertvalue { i64 } undef, i64 %x, 0
ret { i64 } %res
}
define i64 @caller(i64* %p) {
%s = call { i64 } @opaque_callee()
%x = extractvalue { i64 } %s, 0
call { i64 } @callee(i64 %x), !noalias !2
%y = load i64, i64* %p, !alias.scope !2
ret i64 %y
}
!0 = !{#0, !"domain"}
!1 = !{#1, !0, !"scope"}
!2 = !{#1}
; RUN: opt -S -inline < %s
declare { i64 } @opaque_callee()
define { i64 } @callee(i64 %x) {
%res = insertvalue { i64 } undef, i64 %x, 0
ret { i64 } %res
}
define i64 @caller(i64* %p) {
%s = call { i64 } @opaque_callee(), !noalias !0
%x = extractvalue { i64 } %s, 0
%y = load i64, i64* %p, align 4, !alias.scope !0
ret i64 %y
}
!0 = !{#1}
!1 = distinct !{#1, !2, !"scope"}
!2 = distinct !{#2, !"domain"}
The !noalias metadata on the @callee() call is propagated to the @opaque_callee() call from the caller.
This happens because VMap may map to instructions from the caller if simplification occurred. The existing check in
llvm-project/llvm/lib/Transforms/Utils/InlineFunction.cpp
Lines 796 to 799 in d4bdeca
I believe the same basic problem also applies to a few other VMap walks inside the inliner.
This was originally reported at rust-lang/rust#84958.
The text was updated successfully, but these errors were encountered: