|
1 | 1 | //! Codegen of a single function
|
2 | 2 |
|
3 | 3 | use cranelift_codegen::binemit::{NullStackMapSink, NullTrapSink};
|
| 4 | +use rustc_ast::InlineAsmOptions; |
4 | 5 | use rustc_index::vec::IndexVec;
|
5 | 6 | use rustc_middle::ty::adjustment::PointerCast;
|
6 | 7 | use rustc_middle::ty::layout::FnAbiOf;
|
@@ -236,7 +237,8 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
|
236 | 237 | fx.add_comment(inst, terminator_head);
|
237 | 238 | }
|
238 | 239 |
|
239 |
| - fx.set_debug_loc(bb_data.terminator().source_info); |
| 240 | + let source_info = bb_data.terminator().source_info; |
| 241 | + fx.set_debug_loc(source_info); |
240 | 242 |
|
241 | 243 | match &bb_data.terminator().kind {
|
242 | 244 | TerminatorKind::Goto { target } => {
|
@@ -292,19 +294,19 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
|
292 | 294 | let len = codegen_operand(fx, len).load_scalar(fx);
|
293 | 295 | let index = codegen_operand(fx, index).load_scalar(fx);
|
294 | 296 | let location = fx
|
295 |
| - .get_caller_location(bb_data.terminator().source_info.span) |
| 297 | + .get_caller_location(source_info.span) |
296 | 298 | .load_scalar(fx);
|
297 | 299 |
|
298 | 300 | codegen_panic_inner(
|
299 | 301 | fx,
|
300 | 302 | rustc_hir::LangItem::PanicBoundsCheck,
|
301 | 303 | &[index, len, location],
|
302 |
| - bb_data.terminator().source_info.span, |
| 304 | + source_info.span, |
303 | 305 | );
|
304 | 306 | }
|
305 | 307 | _ => {
|
306 | 308 | let msg_str = msg.description();
|
307 |
| - codegen_panic(fx, msg_str, bb_data.terminator().source_info.span); |
| 309 | + codegen_panic(fx, msg_str, source_info.span); |
308 | 310 | }
|
309 | 311 | }
|
310 | 312 | }
|
@@ -375,10 +377,18 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
|
375 | 377 | options,
|
376 | 378 | destination,
|
377 | 379 | line_spans: _,
|
| 380 | + cleanup: _, |
378 | 381 | } => {
|
| 382 | + if options.contains(InlineAsmOptions::MAY_UNWIND) { |
| 383 | + fx.tcx.sess.span_fatal( |
| 384 | + source_info.span, |
| 385 | + "cranelift doesn't support unwinding from inline assembly.", |
| 386 | + ); |
| 387 | + } |
| 388 | + |
379 | 389 | crate::inline_asm::codegen_inline_asm(
|
380 | 390 | fx,
|
381 |
| - bb_data.terminator().source_info.span, |
| 391 | + source_info.span, |
382 | 392 | template,
|
383 | 393 | operands,
|
384 | 394 | *options,
|
@@ -412,7 +422,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) {
|
412 | 422 | }
|
413 | 423 | TerminatorKind::Drop { place, target, unwind: _ } => {
|
414 | 424 | let drop_place = codegen_place(fx, *place);
|
415 |
| - crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place); |
| 425 | + crate::abi::codegen_drop(fx, source_info.span, drop_place); |
416 | 426 |
|
417 | 427 | let target_block = fx.get_block(*target);
|
418 | 428 | fx.bcx.ins().jump(target_block, &[]);
|
|
0 commit comments