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

Get to LLVM-lint-clean #7463

Closed
graydon opened this issue Jun 28, 2013 · 14 comments
Closed

Get to LLVM-lint-clean #7463

graydon opened this issue Jun 28, 2013 · 14 comments
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@graydon
Copy link
Contributor

graydon commented Jun 28, 2013

Not sure what all is involved, but I gather when we turn on LLVM's internal lint checking, all hell breaks loose. Let's tidy this up.

@Blei
Copy link
Contributor

Blei commented Jun 29, 2013

I would say over 90% (not measured) of lint errors are because of bitcasting function pointers, like the ones mentioned in #6779. I have a patch that removes most of them, but is somewhat hacky and not complete yet. But most importantly, it makes the code bigger and doesn't seem to help time-wise either. According to the LLVM IRC channel, those lint errors are false positives.

@msullivan
Copy link
Contributor

Nothing new to add.

@thestinger
Copy link
Contributor

A big cause of this is #8720.

@thestinger
Copy link
Contributor

I think most of the rest are caused by type_use (similar to the #8720 issue). Replacing it would mergefunc would be the laziest way of fixing them.

@brson
Copy link
Contributor

brson commented Sep 18, 2013

Not 0.8

@thestinger
Copy link
Contributor

The only remaining lint appears to be many cases of Pessimization: Static alloca outside of entry block.

@steveklabnik
Copy link
Member

Triage: I pinged @Aatch about this on IRC, but I am bad at our build system, and so I have nothing specific to add.

@sanxiyn sanxiyn added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Jan 25, 2015
@tamird
Copy link
Contributor

tamird commented May 29, 2015

@steveklabnik rustc -C passes=lint turns this on.

@steveklabnik
Copy link
Member

steveklabnik commented Jan 3, 2017

Triage: to try this today, do

RUSTFLAGS="-C passes=lint" python x.py build

We are very much not close to clean, though it seems like many of these are similar issues, so it's possible that a fix would fix many of them.

@nagisa
Copy link
Member

nagisa commented Jan 3, 2017

We have 2 broad kinds of warnings coming up while translating rustc:

Undefined behavior: Memory reference address is misaligned
  store i32 %1, i32* %3, !dbg !2710

and

Unusual: noalias argument aliases another argument
  %4 = call zeroext i1 @core::cmp::PartialEq::gt(i8* noalias readonly dereferenceable(1) %1, i8* noalias readonly dereferenceable(1) %3), !dbg !679

The first is very scary, not sure about 2nd.

@matthiaskrgr
Copy link
Member

cargo 0.26.0-nightly (91e36aa86 2018-01-25)
rustc 1.25.0-nightly (bacb5c58d 2018-01-26)

I was giving RUSTFLAGS="-C passes=lint" python x.py build a try and these are the kinds that I got:

Unusual: noalias argument aliases another argument
  %3 = call zeroext i1 @_ZN4core3cmp10PartialOrd2gt17h599e81f888a1fe30E(i8* noalias readonly dereferenceable(1) %0, i8* noalias readonly dereferenceable(1) %2)
Undefined behavior: Buffer overflow
  %3 = load i64, i64* %2, align 1, !range !0
Unusual: Return statement in function with noreturn attribute
  ret void

While doing a debug crater build, ( RUSTFLAGS="-C passes=lint" cargo build in crater repo) this showed up:

Unusual: unreachable immediately preceded by instruction without side effects
  unreachable, !dbg !69

@steveklabnik
Copy link
Member

Still getting a bunch of

Unusual: Return statement in function with noreturn attribute=>        ] 19/22: alloc
  ret void
   Compiling panic_unwind v0.0.0 (C:\Users\steve\src\rust\src\libpanic_unwind)
Unusual: Return statement in function with noreturn attribute======>   ] 21/22: std
  ret void

Centril added a commit to Centril/rust that referenced this issue Apr 3, 2019
Never return uninhabited values at all

Functions with uninhabited return values are already marked `noreturn`,
but we were still generating return instructions for this. When running
with `C passes=lint`, LLVM prints:

    Unusual: Return statement in function with noreturn attribute

The LLVM manual makes a stronger statement about `noreturn` though:

> This produces undefined behavior at runtime if the function ever does
dynamically return.

We now mark such return values with a new `IgnoreMode::Uninhabited`, and
emit an `abort` anywhere that would have returned.

Fixes rust-lang#48227
cc rust-lang#7463 rust-lang#48229

r? @eddyb
Centril added a commit to Centril/rust that referenced this issue Apr 3, 2019
Never return uninhabited values at all

Functions with uninhabited return values are already marked `noreturn`,
but we were still generating return instructions for this. When running
with `C passes=lint`, LLVM prints:

    Unusual: Return statement in function with noreturn attribute

The LLVM manual makes a stronger statement about `noreturn` though:

> This produces undefined behavior at runtime if the function ever does
dynamically return.

We now mark such return values with a new `IgnoreMode::Uninhabited`, and
emit an `abort` anywhere that would have returned.

Fixes rust-lang#48227
cc rust-lang#7463 rust-lang#48229

r? @eddyb
@cuviper
Copy link
Member

cuviper commented Apr 4, 2019

Unusual: Return statement in function with noreturn attribute

These should be cleaned up by #59639.

Unusual: noalias argument aliases another argument

I believe these are a false positive by the lint -- it should be fine for noalias arguments to point to the same memory when they're both readonly, as there's no possible memory dependence. I've opened LLVM D60239 to try to recognize that.

Centril added a commit to Centril/rust that referenced this issue Apr 4, 2019
Never return uninhabited values at all

Functions with uninhabited return values are already marked `noreturn`,
but we were still generating return instructions for this. When running
with `-C passes=lint`, LLVM prints:

    Unusual: Return statement in function with noreturn attribute

The LLVM manual makes a stronger statement about `noreturn` though:

> This produces undefined behavior at runtime if the function ever does
dynamically return.

We now emit an `abort` anywhere that would have tried to return an
uninhabited value.

Fixes rust-lang#48227
cc rust-lang#7463 rust-lang#48229

r? @eddyb
Centril added a commit to Centril/rust that referenced this issue Apr 4, 2019
Never return uninhabited values at all

Functions with uninhabited return values are already marked `noreturn`,
but we were still generating return instructions for this. When running
with `-C passes=lint`, LLVM prints:

    Unusual: Return statement in function with noreturn attribute

The LLVM manual makes a stronger statement about `noreturn` though:

> This produces undefined behavior at runtime if the function ever does
dynamically return.

We now emit an `abort` anywhere that would have tried to return an
uninhabited value.

Fixes rust-lang#48227
cc rust-lang#7463 rust-lang#48229

r? @eddyb
Centril added a commit to Centril/rust that referenced this issue Apr 4, 2019
Never return uninhabited values at all

Functions with uninhabited return values are already marked `noreturn`,
but we were still generating return instructions for this. When running
with `-C passes=lint`, LLVM prints:

    Unusual: Return statement in function with noreturn attribute

The LLVM manual makes a stronger statement about `noreturn` though:

> This produces undefined behavior at runtime if the function ever does
dynamically return.

We now emit an `abort` anywhere that would have tried to return an
uninhabited value.

Fixes rust-lang#48227
cc rust-lang#7463 rust-lang#48229

r? @eddyb
Centril added a commit to Centril/rust that referenced this issue Apr 4, 2019
Never return uninhabited values at all

Functions with uninhabited return values are already marked `noreturn`,
but we were still generating return instructions for this. When running
with `-C passes=lint`, LLVM prints:

    Unusual: Return statement in function with noreturn attribute

The LLVM manual makes a stronger statement about `noreturn` though:

> This produces undefined behavior at runtime if the function ever does
dynamically return.

We now emit an `abort` anywhere that would have tried to return an
uninhabited value.

Fixes rust-lang#48227
cc rust-lang#7463 rust-lang#48229

r? @eddyb
Centril added a commit to Centril/rust that referenced this issue Apr 4, 2019
Never return uninhabited values at all

Functions with uninhabited return values are already marked `noreturn`,
but we were still generating return instructions for this. When running
with `-C passes=lint`, LLVM prints:

    Unusual: Return statement in function with noreturn attribute

The LLVM manual makes a stronger statement about `noreturn` though:

> This produces undefined behavior at runtime if the function ever does
dynamically return.

We now emit an `abort` anywhere that would have tried to return an
uninhabited value.

Fixes rust-lang#48227
cc rust-lang#7463 rust-lang#48229

r? @eddyb
@Mark-Simulacrum
Copy link
Member

Running a full x.py build I can't seem to get any warnings today so I'm going to presume we've fixed this (or LLVM has moved on and doesn't emit as many lints as previously); either way, closing until we get a reliable reproduction.

flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 6, 2021
Fix `any()` not taking reference in `search_is_some` lint

`find` gives reference to the item, but `any` does not, so suggestion is broken in some specific cases.

Fixes: rust-lang#7392

changelog: [`search_is_some`] Fix suggestion for `any()` not taking item by reference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests