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
[NewGVN] Simplification based on metadata/attributes not available on all members of a congruence class causes miscompiles #36888
Comments
assigned to @fhahn |
Proposed simple fix https://reviews.llvm.org/D47143 |
llvm/llvm-bugzilla-archive#37660 covers a related case, where we have Eli also indicated at https://reviews.llvm.org/D47143 that it would be good to fix those issues there too. |
*** Bug llvm/llvm-bugzilla-archive#37660 has been marked as a duplicate of this bug. *** |
*** Bug llvm/llvm-bugzilla-archive#38260 has been marked as a duplicate of this bug. *** |
*** Bug llvm/llvm-bugzilla-archive#38214 has been marked as a duplicate of this bug. *** |
*** Bug llvm/llvm-bugzilla-archive#38304 has been marked as a duplicate of this bug. *** |
Thanks Florian for fixing this! |
mentioned in issue llvm/llvm-bugzilla-archive#37660 |
mentioned in issue llvm/llvm-bugzilla-archive#38214 |
mentioned in issue llvm/llvm-bugzilla-archive#38260 |
mentioned in issue llvm/llvm-bugzilla-archive#38304 |
Extended Description
NewGVN optimizes:
define i1 @test({}** %arg, i1 %arg2) {
br i1 %arg2, label %bb1, label %bb2
bb1:
%load1 = load {}, {}** %arg
%cmp1 = icmp eq {} %load1, null
ret i1 %cmp1
bb2:
%load2 = load {}, {}** %arg, !nonnull !1
%cmp2 = icmp eq {} %load2, null
ret i1 %cmp2
}
!1 = !{}
into:
define i1 @test({}** %arg, i1 %arg2) {
br i1 %arg2, label %bb1, label %bb2
bb1: ; preds = %0
ret i1 false
bb2: ; preds = %0
ret i1 false
}
The reason is that %load1 and %load2 are found congruent with %load2 chosen as leader. Thus %cmp1 in bb1 calls SimplifyCmp with icmp eq {}* %load2, null, which is simplified to i1 false based on the !nonnull metadata of %load2. However, this metadata is not applicable in this branch.
This bug prevents bootstrapping of rustc under newgvn.
The text was updated successfully, but these errors were encountered: