Skip to content

Commit 1a6358a

Browse files
cuviperalexcrichton
authored andcommitted
Let LLVM 5 add DW_OP_deref to indirect args itself
We needed to manually added the `DW_OP_deref` ourselves in earlier LLVM, but starting with [D31439] in LLVM 5, it appears that LLVM will always handle this itself. When we were still adding this manually, the resulting `.debug_loc` had too many derefs, and this failed test `debuginfo/by-value-self-argument-in-trait-impl.rs`. [D31439]: https://reviews.llvm.org/D31439 Fixes #47611. cc @alexcrichton r? @michaelwoerister
1 parent cf5b520 commit 1a6358a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/librustc_trans/mir/mod.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -487,16 +487,18 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
487487
// The Rust ABI passes indirect variables using a pointer and a manual copy, so we
488488
// need to insert a deref here, but the C ABI uses a pointer and a copy using the
489489
// byval attribute, for which LLVM does the deref itself, so we must not add it.
490+
// Starting with D31439 in LLVM 5, it *always* does the deref itself.
490491
let mut variable_access = VariableAccess::DirectVariable {
491492
alloca: place.llval
492493
};
493-
494-
if let PassMode::Indirect(ref attrs) = arg.mode {
495-
if !attrs.contains(ArgAttribute::ByVal) {
496-
variable_access = VariableAccess::IndirectVariable {
497-
alloca: place.llval,
498-
address_operations: &deref_op,
499-
};
494+
if unsafe { llvm::LLVMRustVersionMajor() < 5 } {
495+
if let PassMode::Indirect(ref attrs) = arg.mode {
496+
if !attrs.contains(ArgAttribute::ByVal) {
497+
variable_access = VariableAccess::IndirectVariable {
498+
alloca: place.llval,
499+
address_operations: &deref_op,
500+
};
501+
}
500502
}
501503
}
502504

0 commit comments

Comments
 (0)