Closed
Description
In the following code, there is an extra layer of indirection in foo
in the final code.
pub struct IString(uint);
impl Eq for IString {
fn eq(&self, other: &IString) -> bool { **self == **other }
fn ne(&self, other: &IString) -> bool { **self != **other }
}
pub fn foo(a: IString, b: IString) -> bool { a==b }
pub fn bar(a: uint, b: uint) -> bool { a==b }
Compiling with -O -S
generates the following (trimmed to the relevant parts):
_ZN3foo17_4341c964988316ba3_00E:
movq (%rdx), %rax
cmpq (%rcx), %rax
sete %al
popq %rbp
ret
_ZN3bar16_df80e259bc1a8923_00E:
cmpq %rcx, %rdx
sete %al
popq %rbp
ret
i.e. the IString
s are passed as pointers, not directly in registers.
(I'm on x64 linux.)
Metadata
Metadata
Assignees
Labels
No labels