about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-28 16:27:56 +0000
committerbors <bors@rust-lang.org>2022-10-28 16:27:56 +0000
commit77e7b74ad5c0c449fa378faf5edf33dd2e6fed87 (patch)
treeb87d8338fb7271b80cab290bb918e7d5e4413907 /src/test/codegen
parent5237c4d83db0a04a0119918b174ee642acd82d9c (diff)
parent34d90a46dac95d6f09cd8851b71b43350eecda4d (diff)
downloadrust-77e7b74ad5c0c449fa378faf5edf33dd2e6fed87.tar.gz
rust-77e7b74ad5c0c449fa378faf5edf33dd2e6fed87.zip
Auto merge of #103071 - wesleywiser:fix_inlined_line_numbers, r=davidtwco
Fix line numbers for MIR inlined code

`should_collapse_debuginfo` detects if the specified span is part of a
macro expansion however it does this by checking if the span is anything
other than a normal (non-expanded) kind, then the span sequence is
walked backwards to the root span.

This doesn't work when the MIR inliner inlines code as it creates spans
with expansion information set to `ExprKind::Inlined` and results in the
line number being attributed to the inline callsite rather than the
normal line number of the inlined code.

Fixes #103068
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/mir-inlined-line-numbers.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/codegen/mir-inlined-line-numbers.rs b/src/test/codegen/mir-inlined-line-numbers.rs
new file mode 100644
index 00000000000..19d83f0eee7
--- /dev/null
+++ b/src/test/codegen/mir-inlined-line-numbers.rs
@@ -0,0 +1,25 @@
+// compile-flags: -O -g
+
+#![crate_type = "lib"]
+
+#[inline(always)]
+fn foo() {
+    bar();
+}
+
+#[inline(never)]
+#[no_mangle]
+fn bar() {
+    panic!();
+}
+
+#[no_mangle]
+pub fn example() {
+    foo();
+}
+
+// CHECK-LABEL: @example
+// CHECK:   tail call void @bar(), !dbg [[DBG_ID:![0-9]+]]
+// CHECK: [[DBG_ID]] = !DILocation(line: 7,
+// CHECK-SAME:                     inlinedAt: [[INLINE_ID:![0-9]+]])
+// CHECK: [[INLINE_ID]] = !DILocation(line: 18,