Skip to content

Instantly share code, notes, and snippets.

@oyvindln
Last active May 11, 2017 12:49
Show Gist options
  • Save oyvindln/bda3c6efb9c428c8bcf12acee8f3f223 to your computer and use it in GitHub Desktop.
Save oyvindln/bda3c6efb9c428c8bcf12acee8f3f223 to your computer and use it in GitHub Desktop.
Box inlining
.text
.file "test2.cgu-0.rs"
.section .text._ZN5test25clone17h3c4e58d6a2d910d1E,"ax",@progbits
.globl _ZN5test25clone17h3c4e58d6a2d910d1E
.p2align 4, 0x90
.type _ZN5test25clone17h3c4e58d6a2d910d1E,@function
_ZN5test25clone17h3c4e58d6a2d910d1E:
.cfi_startproc
pushq %rbx
.Lcfi0:
.cfi_def_cfa_offset 16
subq $8192, %rsp
.Lcfi1:
.cfi_def_cfa_offset 8208
.Lcfi2:
.cfi_offset %rbx, -16
movq (%rdi), %rsi
movq %rsp, %rdi
movl $8192, %edx
callq memcpy@PLT
movl $8192, %edi
movl $8, %esi
callq __rust_allocate@PLT
movq %rax, %rbx
testq %rbx, %rbx
je .LBB0_2
movq %rsp, %rsi
movl $8192, %edx
movq %rbx, %rdi
callq memcpy@PLT
movq %rbx, %rax
addq $8192, %rsp
popq %rbx
retq
.LBB0_2:
callq _ZN5alloc3oom3oom17h6e5f2c39da918c53E@PLT
.Lfunc_end0:
.size _ZN5test25clone17h3c4e58d6a2d910d1E, .Lfunc_end0-_ZN5test25clone17h3c4e58d6a2d910d1E
.cfi_endproc
.section ".note.GNU-stack","",@progbits
const clone::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 1024usize; // scope 0 at test2.rs:2:63: 2:67
return; // scope 0 at test2.rs:2:63: 2:67
}
}
const clone::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 1024usize; // scope 0 at test2.rs:2:42: 2:46
return; // scope 0 at test2.rs:2:42: 2:46
}
}
fn clone(_1: &mut std::boxed::Box<[u64; 1024]>) -> std::boxed::Box<[u64; 1024]> {
let mut _0: std::boxed::Box<[u64; 1024]>; // return pointer
scope 1 {
let _2: &mut std::boxed::Box<[u64; 1024]>; // "bits" in scope 1 at test2.rs:2:21: 2:25
}
let mut _3: [u64; 1024];
bb0: {
StorageLive(_2); // scope 0 at test2.rs:2:21: 2:25
_2 = _1; // scope 0 at test2.rs:2:21: 2:25
StorageLive(_3); // scope 1 at test2.rs:3:12: 3:18
_3 = (*(*_2)); // scope 1 at test2.rs:3:12: 3:18
_0 = const <std::boxed::Box<T>>::new(_3) -> bb1; // scope 1 at test2.rs:3:3: 3:19
}
bb1: {
StorageDead(_3); // scope 1 at test2.rs:3:19: 3:19
StorageDead(_2); // scope 0 at test2.rs:4:2: 4:2
return; // scope 1 at test2.rs:4:2: 4:2
}
}
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
const clone::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 1024usize; // scope 0 at test2.rs:2:63: 2:67
return; // scope 0 at test2.rs:2:63: 2:67
}
}
const clone::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 1024usize; // scope 0 at test2.rs:2:42: 2:46
return; // scope 0 at test2.rs:2:42: 2:46
}
}
fn clone(_1: &mut std::boxed::Box<[u64; 1024]>) -> std::boxed::Box<[u64; 1024]> {
let mut _0: std::boxed::Box<[u64; 1024]>; // return pointer
scope 1 {
scope 2 {
}
}
scope 3 {
}
let mut _2: [u64; 1024];
let mut _3: std::boxed::Box<[u64; 1024]>;
bb0: {
nop; // scope 0 at test2.rs:2:21: 2:25
nop; // scope 0 at test2.rs:2:21: 2:25
nop; // scope 1 at test2.rs:3:12: 3:18
_2 = (*(*_1)); // scope 1 at test2.rs:3:12: 3:18
nop; // scope 2 at /checkout/src/liballoc/boxed.rs:238:16: 238:17
nop; // scope 2 at /checkout/src/liballoc/boxed.rs:238:16: 238:17
_3 = Box([u64; 1024]); // scope 3 at /checkout/src/liballoc/boxed.rs:239:9: 239:14
nop; // scope 3 at /checkout/src/liballoc/boxed.rs:239:13: 239:14
nop; // scope 3 at /checkout/src/liballoc/boxed.rs:239:13: 239:14
(*_3) = _2; // scope 3 at /checkout/src/liballoc/boxed.rs:239:13: 239:14
nop; // scope 3 at /checkout/src/liballoc/boxed.rs:239:14: 239:14
_0 = _3; // scope 3 at /checkout/src/liballoc/boxed.rs:239:9: 239:14
nop; // scope 2 at /checkout/src/liballoc/boxed.rs:240:6: 240:6
nop; // scope 1 at test2.rs:3:19: 3:19
nop; // scope 0 at test2.rs:4:2: 4:2
return; // scope 1 at test2.rs:4:2: 4:2
}
}
#![crate_type = "lib"]
#![feature(box_syntax)]
pub fn create_boxed_array() -> Box<[u16; 100]> {
Box::new([100u16; 100])
}
/*pub fn create_vec() -> Vec<u16> {
vec![100;100]
}
*/
pub fn create_boxed_array2() -> Box<[u16; 100]> {
box [100u16; 100]
}
const create_boxed_array2::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 100usize; // scope 0 at test.rs:13:18: 13:21
return; // scope 0 at test.rs:13:18: 13:21
}
}
const create_boxed_array::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 100usize; // scope 0 at test.rs:4:42: 4:45
return; // scope 0 at test.rs:4:42: 4:45
}
}
const create_boxed_array2::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 100usize; // scope 0 at test.rs:12:43: 12:46
return; // scope 0 at test.rs:12:43: 12:46
}
}
fn create_boxed_array2() -> std::boxed::Box<[u16; 100]> {
let mut _0: std::boxed::Box<[u16; 100]>; // return pointer
let mut _1: std::boxed::Box<[u16; 100]>;
bb0: {
_1 = Box([u16; 100]); // scope 0 at test.rs:13:5: 13:22
(*_1) = [const 100u16; Us64(100)]; // scope 0 at test.rs:13:9: 13:22
_0 = _1; // scope 0 at test.rs:13:5: 13:22
return; // scope 0 at test.rs:14:2: 14:2
}
}
const create_boxed_array::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 100usize; // scope 0 at test.rs:5:23: 5:26
return; // scope 0 at test.rs:5:23: 5:26
}
}
fn create_boxed_array() -> std::boxed::Box<[u16; 100]> {
let mut _0: std::boxed::Box<[u16; 100]>; // return pointer
let mut _1: [u16; 100];
bb0: {
StorageLive(_1); // scope 0 at test.rs:5:14: 5:27
_1 = [const 100u16; Us64(100)]; // scope 0 at test.rs:5:14: 5:27
_0 = const <std::boxed::Box<T>>::new(_1) -> bb1; // scope 0 at test.rs:5:5: 5:28
}
bb1: {
StorageDead(_1); // scope 0 at test.rs:5:28: 5:28
return; // scope 0 at test.rs:6:2: 6:2
}
}
.text
.file "test.cgu-0.rs"
.section .rodata.cst16,"aM",@progbits,16
.p2align 4
.LCPI0_0:
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.section .text._ZN4test18create_boxed_array17hbc7a0febfb0f5053E,"ax",@progbits
.globl _ZN4test18create_boxed_array17hbc7a0febfb0f5053E
.p2align 4, 0x90
.type _ZN4test18create_boxed_array17hbc7a0febfb0f5053E,@function
_ZN4test18create_boxed_array17hbc7a0febfb0f5053E:
.cfi_startproc
pushq %rbx
.Lcfi0:
.cfi_def_cfa_offset 16
subq $400, %rsp
.Lcfi1:
.cfi_def_cfa_offset 416
.Lcfi2:
.cfi_offset %rbx, -16
movaps .LCPI0_0(%rip), %xmm0
movaps %xmm0, (%rsp)
movaps %xmm0, 16(%rsp)
movaps %xmm0, 32(%rsp)
movaps %xmm0, 48(%rsp)
movaps %xmm0, 64(%rsp)
movaps %xmm0, 80(%rsp)
movaps %xmm0, 96(%rsp)
movaps %xmm0, 112(%rsp)
movaps %xmm0, 128(%rsp)
movaps %xmm0, 144(%rsp)
movaps %xmm0, 160(%rsp)
movaps %xmm0, 176(%rsp)
movabsq $28147927174348900, %rax
movq %rax, 192(%rsp)
leaq 200(%rsp), %rdi
movq %rsp, %rsi
movl $200, %edx
callq memcpy@PLT
movl $200, %edi
movl $2, %esi
callq __rust_allocate@PLT
movq %rax, %rbx
testq %rbx, %rbx
je .LBB0_2
leaq 200(%rsp), %rsi
movl $200, %edx
movq %rbx, %rdi
callq memcpy@PLT
movq %rbx, %rax
addq $400, %rsp
popq %rbx
retq
.LBB0_2:
callq _ZN5alloc3oom3oom17h6e5f2c39da918c53E@PLT
.Lfunc_end0:
.size _ZN4test18create_boxed_array17hbc7a0febfb0f5053E, .Lfunc_end0-_ZN4test18create_boxed_array17hbc7a0febfb0f5053E
.cfi_endproc
.section .rodata.cst16,"aM",@progbits,16
.p2align 4
.LCPI1_0:
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.section .text._ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE,"ax",@progbits
.globl _ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE
.p2align 4, 0x90
.type _ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE,@function
_ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE:
.cfi_startproc
pushq %rax
.Lcfi3:
.cfi_def_cfa_offset 16
movl $200, %edi
movl $2, %esi
callq __rust_allocate@PLT
testq %rax, %rax
je .LBB1_2
movaps .LCPI1_0(%rip), %xmm0
movups %xmm0, (%rax)
movups %xmm0, 16(%rax)
movups %xmm0, 32(%rax)
movups %xmm0, 48(%rax)
movups %xmm0, 64(%rax)
movups %xmm0, 80(%rax)
movups %xmm0, 96(%rax)
movups %xmm0, 112(%rax)
movups %xmm0, 128(%rax)
movups %xmm0, 144(%rax)
movups %xmm0, 160(%rax)
movups %xmm0, 176(%rax)
movabsq $28147927174348900, %rcx
movq %rcx, 192(%rax)
popq %rcx
retq
.LBB1_2:
callq _ZN5alloc3oom3oom17h6e5f2c39da918c53E@PLT
.Lfunc_end1:
.size _ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE, .Lfunc_end1-_ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE
.cfi_endproc
.section ".note.GNU-stack","",@progbits
const create_boxed_array2::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 100usize; // scope 0 at test.rs:13:18: 13:21
return; // scope 0 at test.rs:13:18: 13:21
}
}
const create_boxed_array::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 100usize; // scope 0 at test.rs:4:42: 4:45
return; // scope 0 at test.rs:4:42: 4:45
}
}
const create_boxed_array2::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 100usize; // scope 0 at test.rs:12:43: 12:46
return; // scope 0 at test.rs:12:43: 12:46
}
}
fn create_boxed_array2() -> std::boxed::Box<[u16; 100]> {
let mut _0: std::boxed::Box<[u16; 100]>; // return pointer
let mut _1: std::boxed::Box<[u16; 100]>;
bb0: {
_1 = Box([u16; 100]); // scope 0 at test.rs:13:5: 13:22
(*_1) = [const 100u16; Us64(100)]; // scope 0 at test.rs:13:9: 13:22
_0 = _1; // scope 0 at test.rs:13:5: 13:22
return; // scope 0 at test.rs:14:2: 14:2
}
}
const create_boxed_array::{{initializer}}: usize = {
let mut _0: usize; // return pointer
bb0: {
_0 = const 100usize; // scope 0 at test.rs:5:23: 5:26
return; // scope 0 at test.rs:5:23: 5:26
}
}
fn create_boxed_array() -> std::boxed::Box<[u16; 100]> {
let mut _0: std::boxed::Box<[u16; 100]>; // return pointer
scope 1 {
}
scope 2 {
}
let mut _1: [u16; 100];
let mut _2: std::boxed::Box<[u16; 100]>;
bb0: {
nop; // scope 0 at test.rs:5:14: 5:27
_1 = [const 100u16; Us64(100)]; // scope 0 at test.rs:5:14: 5:27
nop; // scope 1 at /checkout/src/liballoc/boxed.rs:238:16: 238:17
nop; // scope 1 at /checkout/src/liballoc/boxed.rs:238:16: 238:17
_2 = Box([u16; 100]); // scope 2 at /checkout/src/liballoc/boxed.rs:239:9: 239:14
nop; // scope 2 at /checkout/src/liballoc/boxed.rs:239:13: 239:14
nop; // scope 2 at /checkout/src/liballoc/boxed.rs:239:13: 239:14
(*_2) = _1; // scope 2 at /checkout/src/liballoc/boxed.rs:239:13: 239:14
nop; // scope 2 at /checkout/src/liballoc/boxed.rs:239:14: 239:14
_0 = _2; // scope 2 at /checkout/src/liballoc/boxed.rs:239:9: 239:14
nop; // scope 1 at /checkout/src/liballoc/boxed.rs:240:6: 240:6
nop; // scope 0 at test.rs:5:28: 5:28
return; // scope 0 at test.rs:6:2: 6:2
}
}
.text
.file "test.cgu-0.rs"
.section .rodata.cst16,"aM",@progbits,16
.p2align 4
.LCPI0_0:
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.section .text._ZN4test18create_boxed_array17hbc7a0febfb0f5053E,"ax",@progbits
.globl _ZN4test18create_boxed_array17hbc7a0febfb0f5053E
.p2align 4, 0x90
.type _ZN4test18create_boxed_array17hbc7a0febfb0f5053E,@function
_ZN4test18create_boxed_array17hbc7a0febfb0f5053E:
.cfi_startproc
pushq %rbx
.Lcfi0:
.cfi_def_cfa_offset 16
subq $208, %rsp
.Lcfi1:
.cfi_def_cfa_offset 224
.Lcfi2:
.cfi_offset %rbx, -16
movaps .LCPI0_0(%rip), %xmm0
movaps %xmm0, (%rsp)
movaps %xmm0, 16(%rsp)
movaps %xmm0, 32(%rsp)
movaps %xmm0, 48(%rsp)
movaps %xmm0, 64(%rsp)
movaps %xmm0, 80(%rsp)
movaps %xmm0, 96(%rsp)
movaps %xmm0, 112(%rsp)
movaps %xmm0, 128(%rsp)
movaps %xmm0, 144(%rsp)
movaps %xmm0, 160(%rsp)
movaps %xmm0, 176(%rsp)
movabsq $28147927174348900, %rax
movq %rax, 192(%rsp)
movl $200, %edi
movl $2, %esi
callq __rust_allocate@PLT
movq %rax, %rbx
testq %rbx, %rbx
je .LBB0_2
movq %rsp, %rsi
movl $200, %edx
movq %rbx, %rdi
callq memcpy@PLT
movq %rbx, %rax
addq $208, %rsp
popq %rbx
retq
.LBB0_2:
callq _ZN5alloc3oom3oom17h6e5f2c39da918c53E@PLT
.Lfunc_end0:
.size _ZN4test18create_boxed_array17hbc7a0febfb0f5053E, .Lfunc_end0-_ZN4test18create_boxed_array17hbc7a0febfb0f5053E
.cfi_endproc
.section .rodata.cst16,"aM",@progbits,16
.p2align 4
.LCPI1_0:
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.short 100
.section .text._ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE,"ax",@progbits
.globl _ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE
.p2align 4, 0x90
.type _ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE,@function
_ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE:
.cfi_startproc
pushq %rax
.Lcfi3:
.cfi_def_cfa_offset 16
movl $200, %edi
movl $2, %esi
callq __rust_allocate@PLT
testq %rax, %rax
je .LBB1_2
movaps .LCPI1_0(%rip), %xmm0
movups %xmm0, (%rax)
movups %xmm0, 16(%rax)
movups %xmm0, 32(%rax)
movups %xmm0, 48(%rax)
movups %xmm0, 64(%rax)
movups %xmm0, 80(%rax)
movups %xmm0, 96(%rax)
movups %xmm0, 112(%rax)
movups %xmm0, 128(%rax)
movups %xmm0, 144(%rax)
movups %xmm0, 160(%rax)
movups %xmm0, 176(%rax)
movabsq $28147927174348900, %rcx
movq %rcx, 192(%rax)
popq %rcx
retq
.LBB1_2:
callq _ZN5alloc3oom3oom17h6e5f2c39da918c53E@PLT
.Lfunc_end1:
.size _ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE, .Lfunc_end1-_ZN4test19create_boxed_array217h8f3f93c73d0e3e3eE
.cfi_endproc
.section ".note.GNU-stack","",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment