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

Don't copy &Trait and &mut Trait to temporaries for every call. #12246

Closed
wants to merge 1 commit into from

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Feb 13, 2014

No description provided.

@eddyb
Copy link
Member Author

eddyb commented Feb 13, 2014

trait Foo {
    fn foo(&self);
}
pub fn foo(x: &Foo) {
    x.foo();
}
; before
define void @foo::hac36ebd8661e5cd1aj::v0.0({ void (i8*)**, i8* }*) #4 {
entry-block:
  %x = alloca { void (i8*)**, i8* }
  %trait_callee = alloca { void (i8*)**, i8* }
  %1 = bitcast { void (i8*)**, i8* }* %0 to i8*
  %2 = bitcast { void (i8*)**, i8* }* %x to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %1, i64 16, i32 8, i1 false)
  %3 = bitcast { void (i8*)**, i8* }* %x to i8*
  %4 = bitcast { void (i8*)**, i8* }* %trait_callee to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %4, i8* %3, i64 16, i32 8, i1 false)
  %5 = getelementptr inbounds { void (i8*)**, i8* }* %trait_callee, i32 0, i32 1
  %6 = load i8** %5
  %7 = getelementptr inbounds { void (i8*)**, i8* }* %trait_callee, i32 0, i32 0
  %8 = bitcast void (i8*)*** %7 to [1 x i8**]**
  %9 = load [1 x i8**]** %8
  %10 = getelementptr inbounds [1 x i8**]* %9, i32 0, i32 1
  %11 = load i8*** %10
  %12 = bitcast i8** %11 to void (i8*)*
  call void %12(i8* %6)
  ret void
}
; after
define void @foo::hac36ebd8661e5cd1aj::v0.0({ void (i8*)**, i8* }*) #4 {
entry-block:
  %1 = getelementptr inbounds { void (i8*)**, i8* }* %0, i32 0, i32 1
  %2 = load i8** %1
  %3 = getelementptr inbounds { void (i8*)**, i8* }* %0, i32 0, i32 0
  %4 = bitcast void (i8*)*** %3 to [1 x i8**]**
  %5 = load [1 x i8**]** %4
  %6 = getelementptr inbounds [1 x i8**]* %5, i32 0, i32 1
  %7 = load i8*** %6
  %8 = bitcast i8** %7 to void (i8*)*
  call void %8(i8* %2)
  ret void
}

@eddyb eddyb deleted the less-trait-copies branch February 15, 2014 10:01
@eddyb eddyb restored the less-trait-copies branch March 8, 2017 19:04
@eddyb eddyb deleted the less-trait-copies branch March 8, 2017 19:40
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 25, 2022
fix: Fix incorrect hover actions config keys
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants