|
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; |
@@ -239,7 +240,8 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) { |
239 | 240 | fx.add_comment(inst, terminator_head); |
240 | 241 | } |
241 | 242 |
|
242 | | - fx.set_debug_loc(bb_data.terminator().source_info); |
| 243 | + let source_info = bb_data.terminator().source_info; |
| 244 | + fx.set_debug_loc(source_info); |
243 | 245 |
|
244 | 246 | match &bb_data.terminator().kind { |
245 | 247 | TerminatorKind::Goto { target } => { |
@@ -295,19 +297,19 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) { |
295 | 297 | let len = codegen_operand(fx, len).load_scalar(fx); |
296 | 298 | let index = codegen_operand(fx, index).load_scalar(fx); |
297 | 299 | let location = fx |
298 | | - .get_caller_location(bb_data.terminator().source_info.span) |
| 300 | + .get_caller_location(source_info.span) |
299 | 301 | .load_scalar(fx); |
300 | 302 |
|
301 | 303 | codegen_panic_inner( |
302 | 304 | fx, |
303 | 305 | rustc_hir::LangItem::PanicBoundsCheck, |
304 | 306 | &[index, len, location], |
305 | | - bb_data.terminator().source_info.span, |
| 307 | + source_info.span, |
306 | 308 | ); |
307 | 309 | } |
308 | 310 | _ => { |
309 | 311 | let msg_str = msg.description(); |
310 | | - codegen_panic(fx, msg_str, bb_data.terminator().source_info.span); |
| 312 | + codegen_panic(fx, msg_str, source_info.span); |
311 | 313 | } |
312 | 314 | } |
313 | 315 | } |
@@ -378,10 +380,18 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) { |
378 | 380 | options, |
379 | 381 | destination, |
380 | 382 | line_spans: _, |
| 383 | + cleanup: _, |
381 | 384 | } => { |
| 385 | + if options.contains(InlineAsmOptions::MAY_UNWIND) { |
| 386 | + fx.tcx.sess.span_fatal( |
| 387 | + source_info.span, |
| 388 | + "cranelift doesn't support unwinding from inline assembly.", |
| 389 | + ); |
| 390 | + } |
| 391 | + |
382 | 392 | crate::inline_asm::codegen_inline_asm( |
383 | 393 | fx, |
384 | | - bb_data.terminator().source_info.span, |
| 394 | + source_info.span, |
385 | 395 | template, |
386 | 396 | operands, |
387 | 397 | *options, |
@@ -415,7 +425,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, '_>) { |
415 | 425 | } |
416 | 426 | TerminatorKind::Drop { place, target, unwind: _ } => { |
417 | 427 | let drop_place = codegen_place(fx, *place); |
418 | | - crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place); |
| 428 | + crate::abi::codegen_drop(fx, source_info.span, drop_place); |
419 | 429 |
|
420 | 430 | let target_block = fx.get_block(*target); |
421 | 431 | fx.bcx.ins().jump(target_block, &[]); |
|
0 commit comments