Skip to content

Commit a25da5d

Browse files
committed
Support debuginfo for custom MIR.
1 parent 98e8a62 commit a25da5d

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

core/src/intrinsics/mir.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ define!(
361361
#[doc(hidden)]
362362
fn __internal_make_place<T>(place: T) -> *mut T
363363
);
364+
define!(
365+
"mir_debuginfo",
366+
#[doc(hidden)]
367+
fn __debuginfo<T>(name: &'static str, s: T)
368+
);
364369

365370
/// Macro for generating custom MIR.
366371
///
@@ -371,6 +376,7 @@ pub macro mir {
371376
(
372377
$(type RET = $ret_ty:ty ;)?
373378
$(let $local_decl:ident $(: $local_decl_ty:ty)? ;)*
379+
$(debug $dbg_name:ident => $dbg_data:expr ;)*
374380

375381
{
376382
$($entry:tt)*
@@ -394,26 +400,32 @@ pub macro mir {
394400
$(
395401
let $local_decl $(: $local_decl_ty)? ;
396402
)*
397-
398403
::core::intrinsics::mir::__internal_extract_let!($($entry)*);
399404
$(
400405
::core::intrinsics::mir::__internal_extract_let!($($block)*);
401406
)*
402407

403408
{
404-
// Finally, the contents of the basic blocks
405-
::core::intrinsics::mir::__internal_remove_let!({
406-
{}
407-
{ $($entry)* }
408-
});
409+
// Now debuginfo
409410
$(
411+
__debuginfo(stringify!($dbg_name), $dbg_data);
412+
)*
413+
414+
{
415+
// Finally, the contents of the basic blocks
410416
::core::intrinsics::mir::__internal_remove_let!({
411417
{}
412-
{ $($block)* }
418+
{ $($entry)* }
413419
});
414-
)*
420+
$(
421+
::core::intrinsics::mir::__internal_remove_let!({
422+
{}
423+
{ $($block)* }
424+
});
425+
)*
415426

416-
RET
427+
RET
428+
}
417429
}
418430
}
419431
}}

0 commit comments

Comments
 (0)