Skip to content

Regression in by-val self u8s #7285

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

Closed
brson opened this issue Jun 21, 2013 · 1 comment
Closed

Regression in by-val self u8s #7285

brson opened this issue Jun 21, 2013 · 1 comment
Labels
A-codegen Area: Code generation

Comments

@brson
Copy link
Contributor

brson commented Jun 21, 2013

trait to_float {
    fn to_float(self) -> float;
}

impl to_float for u8 {
    fn to_float(self) -> float { 0.0 }
}

pub fn main() {
    println("hello, world");
}
rustc: /opt/dev/rust2/src/llvm/lib/IR/Instructions.cpp:2290: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::Instruction*): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.

dotdash added a commit to dotdash/rust that referenced this issue Jun 29, 2013
Currently we pass all "self" arguments by reference, for the pointer
variants this means that we end up with double indirection which causes
a unnecessary performance hit.

The fix itself is pretty straight-forward and just means that "self"
needs to be handled like any other argument, except for by-value "self"
which still needs to be passed by reference. This is because
non-pointer types can't just be stuffed into the environment slot which
is used to pass "self".

What made things tricky is that there was also a bug in the typechecker
where the method map entries are created. For type impls, that stored
the base type instead of the actual self-type in the method map, e.g.
Foo instead of &Foo for &self. That worked with pass-by-reference, but
fails with pass-by-value which needs the real type.

Code that makes use of methods seems to be about 10% faster with this
change. Also, build times are reduced by about 4%.

Fixes rust-lang#4355, rust-lang#4402, rust-lang#5280, rust-lang#4406 and rust-lang#7285
bors added a commit that referenced this issue Jun 29, 2013
Currently we pass all "self" arguments by reference, for the pointer
variants this means that we end up with double indirection which causes
a unnecessary performance hit.

The fix itself is pretty straight-forward and just means that "self"
needs to be handled like any other argument, except for by-value "self"
which still needs to be passed by reference. This is because
non-pointer types can't just be stuffed into the environment slot which
is used to pass "self".

What made things tricky is that there was also a bug in the typechecker
where the method map entries are created. For type impls, that stored
the base type instead of the actual self-type in the method map, e.g.
Foo instead of &Foo for &self. That worked with pass-by-reference, but
fails with pass-by-value which needs the real type.

Code that makes use of methods seems to be about 10% faster with this
change. Also, build times are reduced by about 4%.

Fixes #4355, #4402, #5280, #4406 and #7285
@thestinger
Copy link
Contributor

Fixed by #7452.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 3, 2021
Move mini-macro to tests/ui/auxilary

changelog: none

Merges `/mini-macro` into `/tests/ui/auxilary/proc_macro_derive.rs`.

The mini-macro crate is an artifact of the distant past. A lot has changed (rust-lang#2284) and it doesn't make sense as a top-level crate anymore. Especially since we can use the auxilary folder to accompolish the same thing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation
Projects
None yet
Development

No branches or pull requests

2 participants