Skip to content

Commit 85e1b4e

Browse files
cjgillotcuviper
authored andcommitted
Do not forget to pass DWARF fragment information to LLVM.
(cherry picked from commit b3bbc22)
1 parent 29c9ed9 commit 85e1b4e

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,23 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
435435
bx.store(place.llval, alloca.llval, alloca.align);
436436

437437
// Point the debug info to `*alloca` for the current variable
438-
bx.dbg_var_addr(dbg_var, dbg_loc, alloca.llval, Size::ZERO, &[Size::ZERO], None);
438+
bx.dbg_var_addr(
439+
dbg_var,
440+
dbg_loc,
441+
alloca.llval,
442+
Size::ZERO,
443+
&[Size::ZERO],
444+
var.fragment,
445+
);
439446
} else {
440-
bx.dbg_var_addr(dbg_var, dbg_loc, base.llval, direct_offset, &indirect_offsets, None);
447+
bx.dbg_var_addr(
448+
dbg_var,
449+
dbg_loc,
450+
base.llval,
451+
direct_offset,
452+
&indirect_offsets,
453+
var.fragment,
454+
);
441455
}
442456
}
443457

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// compile-flags: -g -Zmir-opt-level=0 -Zmir-enable-passes=+ScalarReplacementOfAggregates
2+
// compile-flags: -Cno-prepopulate-passes
3+
4+
#![crate_type = "lib"]
5+
6+
pub struct Endian;
7+
8+
#[allow(dead_code)]
9+
pub struct EndianSlice<'input> {
10+
slice: &'input [u8],
11+
endian: Endian,
12+
}
13+
14+
#[no_mangle]
15+
pub fn test(s: &[u8]) {
16+
// CHECK: void @test(
17+
// CHECK: %slice.dbg.spill1 = alloca { ptr, i64 },
18+
// CHECK: %slice.dbg.spill = alloca %Endian,
19+
// CHECK: %s.dbg.spill = alloca { ptr, i64 },
20+
// CHECK: call void @llvm.dbg.declare(metadata ptr %s.dbg.spill, metadata ![[S:.*]], metadata !DIExpression()),
21+
// CHECK: call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill, metadata ![[SLICE:.*]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 0)),
22+
// CHECK: call void @llvm.dbg.declare(metadata ptr %slice.dbg.spill1, metadata ![[SLICE]], metadata !DIExpression()),
23+
let slice = EndianSlice { slice: s, endian: Endian };
24+
}
25+
26+
// CHECK: ![[S]] = !DILocalVariable(name: "s",
27+
// CHECK: ![[SLICE]] = !DILocalVariable(name: "slice",

0 commit comments

Comments
 (0)