diff --git a/src/librustc_llvm/ffi.rs b/src/librustc_llvm/ffi.rs index b97e37f4c8f..f51e51a88b1 100644 --- a/src/librustc_llvm/ffi.rs +++ b/src/librustc_llvm/ffi.rs @@ -1546,7 +1546,7 @@ extern "C" { InlinedAt: MetadataRef) -> ValueRef; pub fn LLVMRustDIBuilderCreateOpDeref() -> i64; - pub fn LLVMRustDIBuilderCreateOpPlus() -> i64; + pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> i64; pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef); pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef); diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs index 3064e2f7c7a..b367eb6548d 100644 --- a/src/librustc_trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -547,7 +547,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>, let ops = unsafe { [llvm::LLVMRustDIBuilderCreateOpDeref(), - llvm::LLVMRustDIBuilderCreateOpPlus(), + llvm::LLVMRustDIBuilderCreateOpPlusUconst(), byte_offset_of_var_in_env as i64, llvm::LLVMRustDIBuilderCreateOpDeref()] }; diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 95130d596e1..0fe533d447b 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -866,7 +866,14 @@ extern "C" int64_t LLVMRustDIBuilderCreateOpDeref() { return dwarf::DW_OP_deref; } -extern "C" int64_t LLVMRustDIBuilderCreateOpPlus() { return dwarf::DW_OP_plus; } +extern "C" int64_t LLVMRustDIBuilderCreateOpPlusUconst() { +#if LLVM_VERSION_GE(5, 0) + return dwarf::DW_OP_plus_uconst; +#else + // older LLVM used `plus` to behave like `plus_uconst`. + return dwarf::DW_OP_plus; +#endif +} extern "C" void LLVMRustWriteTypeToString(LLVMTypeRef Ty, RustStringRef Str) { RawRustStringOstream OS(Str);