Skip to content

Commit 2677822

Browse files
committed
Remove call_lifetime_intrinsic from cg_ssa
1 parent 1c7a2be commit 2677822

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

src/librustc_codegen_llvm/builder.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,22 +1344,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
13441344
self.call_lifetime_intrinsic("llvm.lifetime.end", ptr, size);
13451345
}
13461346

1347-
fn call_lifetime_intrinsic(&mut self, intrinsic: &str, ptr: &'ll Value, size: Size) {
1348-
if self.cx.sess().opts.optimize == config::OptLevel::No {
1349-
return;
1350-
}
1351-
1352-
let size = size.bytes();
1353-
if size == 0 {
1354-
return;
1355-
}
1356-
1357-
let lifetime_intrinsic = self.cx.get_intrinsic(intrinsic);
1358-
1359-
let ptr = self.pointercast(ptr, self.cx.type_i8p());
1360-
self.call(lifetime_intrinsic, &[self.cx.const_u64(size), ptr], None);
1361-
}
1362-
13631347
fn call(
13641348
&mut self,
13651349
llfn: &'ll Value,
@@ -1414,3 +1398,21 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
14141398
llvm::Attribute::NoInline.apply_callsite(llvm::AttributePlace::Function, llret);
14151399
}
14161400
}
1401+
1402+
impl Builder<'a, 'll, 'tcx> {
1403+
fn call_lifetime_intrinsic(&mut self, intrinsic: &str, ptr: &'ll Value, size: Size) {
1404+
if self.cx.sess().opts.optimize == config::OptLevel::No {
1405+
return;
1406+
}
1407+
1408+
let size = size.bytes();
1409+
if size == 0 {
1410+
return;
1411+
}
1412+
1413+
let lifetime_intrinsic = self.cx.get_intrinsic(intrinsic);
1414+
1415+
let ptr = self.pointercast(ptr, self.cx.type_i8p());
1416+
self.call(lifetime_intrinsic, &[self.cx.const_u64(size), ptr], None);
1417+
}
1418+
}

src/librustc_codegen_ssa/traits/builder.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,18 +297,12 @@ pub trait BuilderMethods<'a, 'tcx: 'a>:
297297
) -> Cow<'b, [Self::Value]>
298298
where
299299
[Self::Value]: ToOwned;
300+
301+
/// Called for `StorageLive`
300302
fn lifetime_start(&mut self, ptr: Self::Value, size: Size);
301-
fn lifetime_end(&mut self, ptr: Self::Value, size: Size);
302303

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

313307
fn call(
314308
&mut self,

0 commit comments

Comments
 (0)