Skip to content

Commit 5728c16

Browse files
committed
LLVM codgen support for unwinding inline assembly
1 parent 948d024 commit 5728c16

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/base.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
239239
fx.add_comment(inst, terminator_head);
240240
}
241241

242-
fx.set_debug_loc(bb_data.terminator().source_info);
242+
let source_info = bb_data.terminator().source_info;
243+
fx.set_debug_loc(source_info);
243244

244245
match &bb_data.terminator().kind {
245246
TerminatorKind::Goto { target } => {
@@ -295,19 +296,19 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
295296
let len = codegen_operand(fx, len).load_scalar(fx);
296297
let index = codegen_operand(fx, index).load_scalar(fx);
297298
let location = fx
298-
.get_caller_location(bb_data.terminator().source_info.span)
299+
.get_caller_location(source_info.span)
299300
.load_scalar(fx);
300301

301302
codegen_panic_inner(
302303
fx,
303304
rustc_hir::LangItem::PanicBoundsCheck,
304305
&[index, len, location],
305-
bb_data.terminator().source_info.span,
306+
source_info.span,
306307
);
307308
}
308309
_ => {
309310
let msg_str = msg.description();
310-
codegen_panic(fx, msg_str, bb_data.terminator().source_info.span);
311+
codegen_panic(fx, msg_str, source_info.span);
311312
}
312313
}
313314
}
@@ -378,10 +379,18 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
378379
options,
379380
destination,
380381
line_spans: _,
382+
cleanup,
381383
} => {
384+
if cleanup.is_some() {
385+
fx.tcx.sess.span_fatal(
386+
source_info.span,
387+
"cranelift doesn't support unwinding from inline assembly.",
388+
);
389+
}
390+
382391
crate::inline_asm::codegen_inline_asm(
383392
fx,
384-
bb_data.terminator().source_info.span,
393+
source_info.span,
385394
template,
386395
operands,
387396
*options,
@@ -415,7 +424,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
415424
}
416425
TerminatorKind::Drop { place, target, unwind: _ } => {
417426
let drop_place = codegen_place(fx, *place);
418-
crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place);
427+
crate::abi::codegen_drop(fx, source_info.span, drop_place);
419428

420429
let target_block = fx.get_block(*target);
421430
fx.bcx.ins().jump(target_block, &[]);

0 commit comments

Comments
 (0)