Skip to content

Commit d848c1e

Browse files
committed
Use LLVMDIBuilderInsertDeclareRecordAtEnd
1 parent cd63070 commit d848c1e

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,17 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
172172
addr_ops.push((fragment.end - fragment.start).bits() as u64);
173173
}
174174

175+
let expr = unsafe {
176+
llvm::LLVMDIBuilderCreateExpression(DIB(self.cx()), addr_ops.as_ptr(), addr_ops.len())
177+
};
178+
175179
unsafe {
176180
// FIXME(eddyb) replace `llvm.dbg.declare` with `llvm.dbg.addr`.
177-
llvm::LLVMRustDIBuilderInsertDeclareAtEnd(
181+
llvm::LLVMDIBuilderInsertDeclareRecordAtEnd(
178182
DIB(self.cx()),
179183
variable_alloca,
180184
dbg_var,
181-
addr_ops.as_ptr(),
182-
addr_ops.len() as c_uint,
185+
expr,
183186
dbg_loc,
184187
self.llbb(),
185188
);

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,21 @@ unsafe extern "C" {
17821782
Data: *const Option<&'ll Metadata>,
17831783
NumElements: size_t,
17841784
) -> &'ll Metadata;
1785+
1786+
pub(crate) fn LLVMDIBuilderCreateExpression<'ll>(
1787+
Builder: &DIBuilder<'ll>,
1788+
Addr: *const u64,
1789+
Length: size_t,
1790+
) -> &'ll Metadata;
1791+
1792+
pub(crate) fn LLVMDIBuilderInsertDeclareRecordAtEnd<'ll>(
1793+
Builder: &DIBuilder<'ll>,
1794+
Storage: &'ll Value,
1795+
VarInfo: &'ll Metadata,
1796+
Expr: &'ll Metadata,
1797+
DebugLoc: &'ll Metadata,
1798+
Block: &'ll BasicBlock,
1799+
) -> &'ll Metadata;
17851800
}
17861801

17871802
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2160,16 +2175,6 @@ unsafe extern "C" {
21602175
AlignInBits: u32,
21612176
) -> &'a DIVariable;
21622177

2163-
pub fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>(
2164-
Builder: &DIBuilder<'a>,
2165-
Val: &'a Value,
2166-
VarInfo: &'a DIVariable,
2167-
AddrOps: *const u64,
2168-
AddrOpsCount: c_uint,
2169-
DL: &'a DILocation,
2170-
InsertAtEnd: &'a BasicBlock,
2171-
);
2172-
21732178
pub fn LLVMRustDIBuilderCreateEnumerator<'a>(
21742179
Builder: &DIBuilder<'a>,
21752180
Name: *const c_char,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,17 +1045,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
10451045
}
10461046
}
10471047

1048-
extern "C" void LLVMRustDIBuilderInsertDeclareAtEnd(
1049-
LLVMRustDIBuilderRef Builder, LLVMValueRef V, LLVMMetadataRef VarInfo,
1050-
uint64_t *AddrOps, unsigned AddrOpsCount, LLVMMetadataRef DL,
1051-
LLVMBasicBlockRef InsertAtEnd) {
1052-
Builder->insertDeclare(unwrap(V), unwrap<DILocalVariable>(VarInfo),
1053-
Builder->createExpression(
1054-
llvm::ArrayRef<uint64_t>(AddrOps, AddrOpsCount)),
1055-
DebugLoc(cast<MDNode>(unwrap(DL))),
1056-
unwrap(InsertAtEnd));
1057-
}
1058-
10591048
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerator(
10601049
LLVMRustDIBuilderRef Builder, const char *Name, size_t NameLen,
10611050
const uint64_t Value[2], unsigned SizeInBits, bool IsUnsigned) {

0 commit comments

Comments
 (0)