Skip to content

Commit 2510636

Browse files
Rollup merge of rust-lang#144034 - Enselic:diverging-function-call-debuginfo, r=wesleywiser
tests: Test line number in debuginfo for diverging function calls Closes rust-lang#59558 which just [E-needs-test](rust-lang#59558 (comment)). The bug seems to have been fixed in **nightly-2021-05-10**: ```sh for toolchain in nightly-2021-05-09 \ nightly-2021-05-10 \ 1.88; do echo -e "\nWith $toolchain:" rustc +$toolchain tests/codegen/diverging-function-call-debuginfo.rs --emit llvm-ir -o /tmp/out.ll -g -Clto -Copt-level=0 build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck --input-file /tmp/out.ll tests/codegen/diverging-function-call-debuginfo.rs --check-prefix=CHECK --dump-input-context 10 2>/dev/null && echo OK || echo FAIL done ``` ``` With nightly-2021-05-09: FAIL With nightly-2021-05-10: OK With 1.88: OK ``` which gives the following list of candidate commits. Not clear which one it is exactly but it doesn't matter much since we can confirm that the test works. I have confirmed locally that with **nightly-2021-05-09** we get `line: 0` for the last call. <details> <summary>click to expand</summary> ``` $ git log ^881c1ac408d93bb7adaa3a51dabab9266e82eee8 ca82264 --no-merges --oneline ``` f25aa57 Remove unused `opt_span_warn` function ebbc949 Note why `Handler::fatal` is different from `Sesssion::fatal` 96509b4 Make `Diagnostic::span_fatal` unconditionally raise an error e49f447 Remove some unnecessary uses of `struct_span_fatal` 955fdae Rename `Parser::span_fatal_err` -> `Parser::span_err` 4b7c8b0 Add `#[track_caller]` to `FakeDefId::expect_real()` ba13225 Remove `FakeDefId::expect_local()` 020d83d Enable `-W semicolon_in_expressions_from_macros` in bootstrap 1b928ff Update LLVM submodule c2b15a6 Support -C passes in NewPM 5519cbf Don't force -O1 with ThinLTO 7c4989a Drop -opt-bisect-limit=0 flag from test db140de Explicitly register GCOV profiling pass as well 5ecbe7f Explicitly register instrprof pass 0318883 Make -Z new-llvm-pass-manager an Option<bool> 0367e24 Avoid predecessors having Drop impls </details>
2 parents 29ebedd + 54a4701 commit 2510636

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/// Make sure that line debuginfo is correct for diverging calls under certain
2+
/// conditions. In particular we want to ensure that the line number is never
3+
/// 0, but we check the absence of 0 by looking for the expected exact line
4+
/// numbers. Regression test for <https://github.com/rust-lang/rust/issues/59558>.
5+
6+
//@ compile-flags: -g -Clto -Copt-level=0
7+
//@ no-prefer-dynamic
8+
9+
// First find the scope of both diverge() calls, namely this main() function.
10+
// CHECK-DAG: [[MAIN_SCOPE:![0-9]+]] = distinct !DISubprogram(name: "main", linkageName: {{.*}}diverging_function_call_debuginfo{{.*}}main{{.*}}
11+
fn main() {
12+
if True == False {
13+
// unreachable
14+
// Then find the DILocation with the correct line number for this call ...
15+
// CHECK-DAG: [[UNREACHABLE_CALL_DBG:![0-9]+]] = !DILocation(line: [[@LINE+1]], {{.*}}scope: [[MAIN_SCOPE]]
16+
diverge();
17+
}
18+
19+
// ... and this call.
20+
// CHECK-DAG: [[LAST_CALL_DBG:![0-9]+]] = !DILocation(line: [[@LINE+1]], {{.*}}scope: [[MAIN_SCOPE]]
21+
diverge();
22+
}
23+
24+
#[derive(PartialEq)]
25+
pub enum MyBool {
26+
True,
27+
False,
28+
}
29+
30+
use MyBool::*;
31+
32+
fn diverge() -> ! {
33+
panic!();
34+
}
35+
36+
// Finally make sure both DILocations belong to each the respective diverge() call.
37+
// CHECK-DAG: call void {{.*}}diverging_function_call_debuginfo{{.*}}diverge{{.*}} !dbg [[LAST_CALL_DBG]]
38+
// CHECK-DAG: call void {{.*}}diverging_function_call_debuginfo{{.*}}diverge{{.*}} !dbg [[UNREACHABLE_CALL_DBG]]

0 commit comments

Comments
 (0)