Skip to content

Commit cb0a8bf

Browse files
authored
Rollup merge of rust-lang#47610 - cuviper:captured-dwarf, r=eddyb
LLVM5: Update DW_OP_plus to DW_OP_plus_uconst LLVM <= 4.0 used a non-standard interpretation of `DW_OP_plus`. In the DWARF standard, this adds two items on the expressions stack. LLVM's behavior was more like DWARF's `DW_OP_plus_uconst` -- adding a constant that follows the op. The patch series starting with [D33892] switched to the standard DWARF interpretation, so we need to follow. [D33892]: https://reviews.llvm.org/D33892 Fixes rust-lang#47464 r? @eddyb
2 parents 52f8d2d + e2f6b28 commit cb0a8bf

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/librustc_llvm/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,7 @@ extern "C" {
15461546
InlinedAt: MetadataRef)
15471547
-> ValueRef;
15481548
pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1549-
pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
1549+
pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64;
15501550

15511551
pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
15521552
pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);

src/librustc_trans/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
547547

548548
let ops = unsafe {
549549
[llvm::LLVMRustDIBuilderCreateOpDeref(),
550-
llvm::LLVMRustDIBuilderCreateOpPlus(),
550+
llvm::LLVMRustDIBuilderCreateOpPlusUconst(),
551551
byte_offset_of_var_in_env as i64,
552552
llvm::LLVMRustDIBuilderCreateOpDeref()]
553553
};

src/rustllvm/RustWrapper.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,14 @@ extern "C" int64_t LLVMRustDIBuilderCreateOpDeref() {
866866
return dwarf::DW_OP_deref;
867867
}
868868

869-
extern "C" int64_t LLVMRustDIBuilderCreateOpPlus() { return dwarf::DW_OP_plus; }
869+
extern "C" int64_t LLVMRustDIBuilderCreateOpPlusUconst() {
870+
#if LLVM_VERSION_GE(5, 0)
871+
return dwarf::DW_OP_plus_uconst;
872+
#else
873+
// older LLVM used `plus` to behave like `plus_uconst`.
874+
return dwarf::DW_OP_plus;
875+
#endif
876+
}
870877

871878
extern "C" void LLVMRustWriteTypeToString(LLVMTypeRef Ty, RustStringRef Str) {
872879
RawRustStringOstream OS(Str);

0 commit comments

Comments
 (0)