Skip to content

Omit lifetime intrinsics for zero-sized types #27960

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

Merged
merged 1 commit into from
Aug 23, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/librustc_trans/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,10 +917,14 @@ pub fn call_lifetime_start(cx: Block, ptr: ValueRef) {
let _icx = push_ctxt("lifetime_start");
let ccx = cx.ccx();

let llsize = C_u64(ccx, machine::llsize_of_alloc(ccx, val_ty(ptr).element_type()));
let size = machine::llsize_of_alloc(ccx, val_ty(ptr).element_type());
if size == 0 {
return;
}

let ptr = PointerCast(cx, ptr, Type::i8p(ccx));
let lifetime_start = ccx.get_intrinsic(&"llvm.lifetime.start");
Call(cx, lifetime_start, &[llsize, ptr], None, DebugLoc::None);
Call(cx, lifetime_start, &[C_u64(ccx, size), ptr], None, DebugLoc::None);
}

pub fn call_lifetime_end(cx: Block, ptr: ValueRef) {
Expand All @@ -931,10 +935,14 @@ pub fn call_lifetime_end(cx: Block, ptr: ValueRef) {
let _icx = push_ctxt("lifetime_end");
let ccx = cx.ccx();

let llsize = C_u64(ccx, machine::llsize_of_alloc(ccx, val_ty(ptr).element_type()));
let size = machine::llsize_of_alloc(ccx, val_ty(ptr).element_type());
if size == 0 {
return;
}

let ptr = PointerCast(cx, ptr, Type::i8p(ccx));
let lifetime_end = ccx.get_intrinsic(&"llvm.lifetime.end");
Call(cx, lifetime_end, &[llsize, ptr], None, DebugLoc::None);
Call(cx, lifetime_end, &[C_u64(ccx, size), ptr], None, DebugLoc::None);
}

pub fn call_memcpy(cx: Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
Expand Down