Skip to content

Commit

Permalink
Remove call_lifetime_intrinsic from cg_ssa
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Nov 29, 2018
1 parent 187c4cf commit 9a90455
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
34 changes: 18 additions & 16 deletions src/librustc_codegen_llvm/builder.rs
Expand Up @@ -1350,22 +1350,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
self.call_lifetime_intrinsic("llvm.lifetime.end", ptr, size);
}

fn call_lifetime_intrinsic(&mut self, intrinsic: &str, ptr: &'ll Value, size: Size) {
if self.cx.sess().opts.optimize == config::OptLevel::No {
return;
}

let size = size.bytes();
if size == 0 {
return;
}

let lifetime_intrinsic = self.cx.get_intrinsic(intrinsic);

let ptr = self.pointercast(ptr, self.cx.type_i8p());
self.call(lifetime_intrinsic, &[self.cx.const_u64(size), ptr], None);
}

fn call(
&mut self,
llfn: &'ll Value,
Expand Down Expand Up @@ -1420,3 +1404,21 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
llvm::Attribute::NoInline.apply_callsite(llvm::AttributePlace::Function, llret);
}
}

impl Builder<'a, 'll, 'tcx> {
fn call_lifetime_intrinsic(&mut self, intrinsic: &str, ptr: &'ll Value, size: Size) {
if self.cx.sess().opts.optimize == config::OptLevel::No {
return;
}

let size = size.bytes();
if size == 0 {
return;
}

let lifetime_intrinsic = self.cx.get_intrinsic(intrinsic);

let ptr = self.pointercast(ptr, self.cx.type_i8p());
self.call(lifetime_intrinsic, &[self.cx.const_u64(size), ptr], None);
}
}
14 changes: 4 additions & 10 deletions src/librustc_codegen_ssa/traits/builder.rs
Expand Up @@ -297,18 +297,12 @@ pub trait BuilderMethods<'a, 'tcx: 'a>:
) -> Cow<'b, [Self::Value]>
where
[Self::Value]: ToOwned;

/// Called for `StorageLive`
fn lifetime_start(&mut self, ptr: Self::Value, size: Size);
fn lifetime_end(&mut self, ptr: Self::Value, size: Size);

/// If LLVM lifetime intrinsic support is enabled (i.e. optimizations
/// on), and `ptr` is nonzero-sized, then extracts the size of `ptr`
/// and the intrinsic for `lt` and passes them to `emit`, which is in
/// charge of generating code to call the passed intrinsic on whatever
/// block of generated code is targeted for the intrinsic.
///
/// If LLVM lifetime intrinsic support is disabled (i.e. optimizations
/// off) or `ptr` is zero-sized, then no-op (does not call `emit`).
fn call_lifetime_intrinsic(&mut self, intrinsic: &str, ptr: Self::Value, size: Size);
/// Called for `StorageDead`
fn lifetime_end(&mut self, ptr: Self::Value, size: Size);

fn call(
&mut self,
Expand Down

0 comments on commit 9a90455

Please sign in to comment.