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

[NewGVN] Simplification based on metadata/attributes not available on all members of a congruence class causes miscompiles #36888

Closed
nikic opened this issue May 21, 2018 · 13 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla llvm:GVN GVN and NewGVN stages (Global value numbering)

Comments

@nikic
Copy link
Contributor

nikic commented May 21, 2018

Bugzilla Link 37540
Resolution FIXED
Resolved on Aug 17, 2018 12:23
Version trunk
OS All
Blocks #30343
CC @efriedma-quic,@fhahn,@hiraditya,@Vsevolod-Livinskij
Fixed by commit(s) r340031

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.

@nikic
Copy link
Contributor Author

nikic commented May 21, 2018

assigned to @fhahn

@fhahn
Copy link
Contributor

fhahn commented May 21, 2018

Proposed simple fix https://reviews.llvm.org/D47143

@fhahn
Copy link
Contributor

fhahn commented Jul 28, 2018

llvm/llvm-bugzilla-archive#37660 covers a related case, where we have shl i64 %1, 32 and shl nsw i64 %1, 32 in a congruence class and we later simplify based on nsw, which does not hold for all members.

Eli also indicated at https://reviews.llvm.org/D47143 that it would be good to fix those issues there too.

@fhahn
Copy link
Contributor

fhahn commented Jul 28, 2018

*** Bug llvm/llvm-bugzilla-archive#37660 has been marked as a duplicate of this bug. ***

@fhahn
Copy link
Contributor

fhahn commented Jul 28, 2018

@fhahn
Copy link
Contributor

fhahn commented Aug 14, 2018

*** Bug llvm/llvm-bugzilla-archive#38260 has been marked as a duplicate of this bug. ***

@fhahn
Copy link
Contributor

fhahn commented Aug 14, 2018

*** Bug llvm/llvm-bugzilla-archive#38214 has been marked as a duplicate of this bug. ***

@fhahn
Copy link
Contributor

fhahn commented Aug 14, 2018

*** Bug llvm/llvm-bugzilla-archive#38304 has been marked as a duplicate of this bug. ***

@hiraditya
Copy link
Collaborator

Thanks Florian for fixing this!

@fhahn
Copy link
Contributor

fhahn commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#37660

@fhahn
Copy link
Contributor

fhahn commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#38214

@fhahn
Copy link
Contributor

fhahn commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#38260

@fhahn
Copy link
Contributor

fhahn commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#38304

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@RKSimon RKSimon added the llvm:GVN GVN and NewGVN stages (Global value numbering) label Jun 14, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:GVN GVN and NewGVN stages (Global value numbering)
Projects
None yet
Development

No branches or pull requests

4 participants