Skip to content

Commit e0dfdd1

Browse files
committed
spirv_asm: use line_spans for slightly better source locations.
1 parent a4538a1 commit e0dfdd1

15 files changed

+45
-48
lines changed

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> {
9595
template: &[InlineAsmTemplatePiece],
9696
operands: &[InlineAsmOperandRef<'tcx, Self>],
9797
options: InlineAsmOptions,
98-
_line_spans: &[Span],
98+
line_spans: &[Span],
9999
_instance: Instance<'_>,
100100
_dest: Option<Self::BasicBlock>,
101101
_catch_funclet: Option<(Self::BasicBlock, Option<&Self::Funclet>)>,
@@ -211,7 +211,17 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> {
211211
}
212212

213213
let mut asm_block = AsmBlock::Open;
214-
for line in tokens {
214+
for (line_idx, line) in tokens.into_iter().enumerate() {
215+
match asm_block {
216+
AsmBlock::Open => {
217+
self.set_span(line_spans.get(line_idx).copied().unwrap_or_default());
218+
}
219+
// FIXME(eddyb) this line is most likely an `OpLabel`, following
220+
// a terminator, and calling `set_span` here will attempt to add
221+
// debuginfo in the previous block (i.e. after the terminator),
222+
// which is an unfortunate interaction, but perhaps avoidable?
223+
AsmBlock::End(_) => {}
224+
}
215225
self.codegen_asm(
216226
&mut id_map,
217227
&mut defined_ids,

tests/compiletests/ui/arch/all_memory_barrier.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 78 8
3+
OpLine %5 82 13
44
OpMemoryBarrier %6 %7
55
OpNoLine
66
OpReturn

tests/compiletests/ui/arch/all_memory_barrier_with_group_sync.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 42 8
3+
OpLine %5 47 13
44
OpControlBarrier %6 %7 %8
55
OpNoLine
66
OpReturn

tests/compiletests/ui/arch/device_memory_barrier.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 78 8
3+
OpLine %5 82 13
44
OpMemoryBarrier %6 %7
55
OpNoLine
66
OpReturn

tests/compiletests/ui/arch/device_memory_barrier_with_group_sync.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 42 8
3+
OpLine %5 47 13
44
OpControlBarrier %6 %7 %8
55
OpNoLine
66
OpReturn

tests/compiletests/ui/arch/subgroup/subgroup_ballot.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpFunctionParameter %2
33
%5 = OpLabel
4-
OpLine %6 373 8
4+
OpLine %6 378 13
55
%7 = OpGroupNonUniformBallot %8 %9 %4
6-
OpLine %6 412 8
6+
OpLine %6 417 13
77
%10 = OpGroupNonUniformInverseBallot %2 %9 %7
88
OpNoLine
99
OpReturnValue %10

tests/compiletests/ui/arch/subgroup/subgroup_broadcast_first.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpFunctionParameter %2
33
%5 = OpLabel
4-
OpLine %6 340 8
4+
OpLine %6 344 13
55
%7 = OpGroupNonUniformBroadcastFirst %2 %8 %4
66
OpNoLine
77
OpReturnValue %7

tests/compiletests/ui/arch/subgroup/subgroup_elect.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 170 8
3+
OpLine %5 174 13
44
%6 = OpGroupNonUniformElect %2 %7
55
OpNoLine
66
OpReturnValue %6

tests/compiletests/ui/arch/workgroup_memory_barrier.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 78 8
3+
OpLine %5 82 13
44
OpMemoryBarrier %6 %7
55
OpNoLine
66
OpReturn

tests/compiletests/ui/arch/workgroup_memory_barrier_with_group_sync.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 42 8
3+
OpLine %5 47 13
44
OpControlBarrier %6 %6 %7
55
OpNoLine
66
OpReturn

0 commit comments

Comments
 (0)