Skip to content

Commit 0d40f89

Browse files
Dynamically generate new block for assert terminator trans.
This removes the unreachable_block cache, since we no longer utilize it.
1 parent 8cee04a commit 0d40f89

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

src/librustc_trans/mir/block.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,6 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
254254
bcx.llbb()
255255
}
256256

257-
pub fn unreachable_block(&mut self) -> BasicBlockRef {
258-
self.unreachable_block.unwrap_or_else(|| {
259-
let bl = self.new_block("unreachable");
260-
bl.unreachable();
261-
self.unreachable_block = Some(bl.llbb());
262-
bl.llbb()
263-
})
264-
}
265-
266257
pub fn new_block(&self, name: &str) -> Builder<'a, 'tcx> {
267258
Builder::new_block(self.ccx, self.llfn, name)
268259
}

src/librustc_trans/mir/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ pub struct MirContext<'a, 'tcx:'a> {
7373
/// and eagerly on MSVC.
7474
landing_pads: IndexVec<mir::Block, Option<BasicBlockRef>>,
7575

76-
/// Cached unreachable block
77-
unreachable_block: Option<BasicBlockRef>,
78-
7976
/// The location where each MIR arg/var/tmp/ret is stored. This is
8077
/// usually an `LvalueRef` representing an alloca, but not always:
8178
/// sometimes we can skip the alloca and just store the value
@@ -236,7 +233,6 @@ pub fn trans_mir<'a, 'tcx: 'a>(
236233
ccx: ccx,
237234
llpersonalityslot: None,
238235
blocks: block_bcxs,
239-
unreachable_block: None,
240236
cleanup_kinds: cleanup_kinds,
241237
landing_pads: IndexVec::from_elem(None, mir.basic_blocks()),
242238
scopes: scopes,

src/librustc_trans/mir/statement.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,19 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
239239

240240
// Translate the actual panic invoke/call.
241241
if let Some(unwind) = cleanup {
242-
bcx.invoke(llfn,
243-
&args,
244-
self.unreachable_block(),
245-
self.landing_pad_to(unwind),
246-
cleanup_bundle);
242+
let old_bcx = bcx;
243+
bcx = old_bcx.build_sibling_block("assert-next");
244+
old_bcx.invoke(
245+
llfn,
246+
&args,
247+
bcx.llbb(),
248+
self.landing_pad_to(unwind),
249+
cleanup_bundle
250+
);
247251
} else {
248252
bcx.call(llfn, &args, cleanup_bundle);
249-
bcx.unreachable();
250253
}
254+
bcx.unreachable();
251255

252256
success_block
253257
}

0 commit comments

Comments
 (0)