Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cuviper committed Jan 20, 2018
1 parent 5965b79 commit e2f6b28
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/librustc_llvm/ffi.rs
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/mir/mod.rs
Expand Up @@ -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()]
};
Expand Down
9 changes: 8 additions & 1 deletion src/rustllvm/RustWrapper.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit e2f6b28

Please sign in to comment.