Skip to content

Commit 613d877

Browse files
committed
Refix #132900 and fix #135332 by emitting locations with dummy spans instead of not emitting locations at all when the correct location discriminator value exceeds LLVM's capacity.
1 parent 0f4bc42 commit 613d877

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::mir::{Body, SourceScope};
99
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv};
1010
use rustc_middle::ty::{self, Instance};
1111
use rustc_session::config::DebugInfo;
12-
use rustc_span::{BytePos, hygiene};
12+
use rustc_span::{BytePos, DUMMY_SP, hygiene};
1313

1414
use super::metadata::file_metadata;
1515
use super::utils::DIB;
@@ -163,8 +163,13 @@ fn make_mir_scope<'ll, 'tcx>(
163163
match discriminators.entry(callsite_span.lo()) {
164164
Entry::Occupied(mut o) => {
165165
*o.get_mut() += 1;
166+
// NB: We have to emit *something* here or we'll fail LLVM IR verification
167+
// in at least some circumstances (see issue #135322) so if the required
168+
// discriminant cannot be encoded fall back to the dummy location.
166169
unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) }
167-
.expect("Failed to encode discriminator in DILocation")
170+
.unwrap_or_else(|| {
171+
cx.dbg_loc(callsite_scope, parent_scope.inlined_at, DUMMY_SP)
172+
})
168173
}
169174
Entry::Vacant(v) => {
170175
v.insert(0);

0 commit comments

Comments
 (0)