Skip to content

Commit c3216d7

Browse files
authored
Auto merge of #37153 - michaelwoerister:spread-arg-debuginfo, r=eddyb
debuginfo: Handle spread_arg case in MIR-trans in a more stable way. Use `VariableAccess::DirectVariable` instead of `VariableAccess::IndirectVariable` in order not to make LLVM's SROA angry. This is a step towards fixing #36774 and #35547. At least, I can build Cargo with optimizations + debuginfo again. r? @eddyb
2 parents 6dc035e + 8d5b523 commit c3216d7

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

src/librustc_trans/mir/mod.rs

+13-21
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
371371
_ => bug!("spread argument isn't a tuple?!")
372372
};
373373

374-
let lltuplety = type_of::type_of(bcx.ccx(), arg_ty);
375374
let lltemp = bcx.with_block(|bcx| {
376375
base::alloc_ty(bcx, arg_ty, &format!("arg{}", arg_index))
377376
});
@@ -391,27 +390,20 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
391390
} else {
392391
arg.store_fn_arg(bcx, &mut llarg_idx, dst);
393392
}
394-
395-
bcx.with_block(|bcx| arg_scope.map(|scope| {
396-
let byte_offset_of_var_in_tuple =
397-
machine::llelement_offset(bcx.ccx(), lltuplety, i);
398-
399-
let ops = unsafe {
400-
[llvm::LLVMRustDIBuilderCreateOpDeref(),
401-
llvm::LLVMRustDIBuilderCreateOpPlus(),
402-
byte_offset_of_var_in_tuple as i64]
403-
};
404-
405-
let variable_access = VariableAccess::IndirectVariable {
406-
alloca: lltemp,
407-
address_operations: &ops
408-
};
409-
declare_local(bcx, keywords::Invalid.name(),
410-
tupled_arg_ty, scope, variable_access,
411-
VariableKind::ArgumentVariable(arg_index + i + 1),
412-
bcx.fcx().span.unwrap_or(DUMMY_SP));
413-
}));
414393
}
394+
395+
// Now that we have one alloca that contains the aggregate value,
396+
// we can create one debuginfo entry for the argument.
397+
bcx.with_block(|bcx| arg_scope.map(|scope| {
398+
let variable_access = VariableAccess::DirectVariable {
399+
alloca: lltemp
400+
};
401+
declare_local(bcx, arg_decl.name.unwrap_or(keywords::Invalid.name()),
402+
arg_ty, scope, variable_access,
403+
VariableKind::ArgumentVariable(arg_index + 1),
404+
bcx.fcx().span.unwrap_or(DUMMY_SP));
405+
}));
406+
415407
return LocalRef::Lvalue(LvalueRef::new_sized(lltemp, LvalueTy::from_ty(arg_ty)));
416408
}
417409

0 commit comments

Comments
 (0)