Skip to content

Commit b3bbc22

Browse files
committed
Do not forget to pass DWARF fragment information to LLVM.
1 parent 25ed43d commit b3bbc22

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

Diff for: compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,23 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
445445
bx.store(place.llval, alloca.llval, alloca.align);
446446

447447
// Point the debug info to `*alloca` for the current variable
448-
bx.dbg_var_addr(dbg_var, dbg_loc, alloca.llval, Size::ZERO, &[Size::ZERO], None);
448+
bx.dbg_var_addr(
449+
dbg_var,
450+
dbg_loc,
451+
alloca.llval,
452+
Size::ZERO,
453+
&[Size::ZERO],
454+
var.fragment,
455+
);
449456
} else {
450-
bx.dbg_var_addr(dbg_var, dbg_loc, base.llval, direct_offset, &indirect_offsets, None);
457+
bx.dbg_var_addr(
458+
dbg_var,
459+
dbg_loc,
460+
base.llval,
461+
direct_offset,
462+
&indirect_offsets,
463+
var.fragment,
464+
);
451465
}
452466
}
453467

Diff for: tests/codegen/sroa-fragment-debuginfo.rs

+27
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)