Skip to content

Commit c6c82ec

Browse files
committed
Use LLVMDIBuilderGetOrCreateSubrange
1 parent 0602787 commit c6c82ec

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::hash::{Hash, Hasher};
44
use std::path::{Path, PathBuf};
55
use std::{iter, ptr};
66

7-
use libc::{c_char, c_longlong, c_uint};
7+
use libc::{c_char, c_uint};
88
use rustc_abi::{Align, Size};
99
use rustc_codegen_ssa::debuginfo::type_names::{VTableNameKind, cpp_like_debuginfo};
1010
use rustc_codegen_ssa::traits::*;
@@ -121,11 +121,16 @@ fn build_fixed_size_array_di_node<'ll, 'tcx>(
121121

122122
let (size, align) = cx.size_and_align_of(array_type);
123123

124-
let upper_bound = len
125-
.try_to_target_usize(cx.tcx)
126-
.expect("expected monomorphic const in codegen") as c_longlong;
124+
let upper_bound =
125+
len.try_to_target_usize(cx.tcx).expect("expected monomorphic const in codegen");
127126

128-
let subrange = unsafe { llvm::LLVMRustDIBuilderGetOrCreateSubrange(DIB(cx), 0, upper_bound) };
127+
let subrange = unsafe {
128+
llvm::LLVMDIBuilderGetOrCreateSubrange(
129+
DIB(cx),
130+
/* LowerBound */ 0i64,
131+
/* Count */ upper_bound as i64,
132+
)
133+
};
129134

130135
let subscripts = &[subrange];
131136
let di_node = unsafe {

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_target::spec::SymbolVisibility;
1212
use super::RustString;
1313
use super::debuginfo::{
1414
DIArray, DIBuilder, DIDerivedType, DIDescriptor, DIEnumerator, DIFile, DIFlags,
15-
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram, DISubrange,
15+
DIGlobalVariableExpression, DILocation, DISPFlags, DIScope, DISubprogram,
1616
DITemplateTypeParameter, DIType, DIVariable, DebugEmissionKind, DebugNameTableKind,
1717
};
1818
use crate::llvm;
@@ -1772,6 +1772,12 @@ unsafe extern "C" {
17721772
Scope: Option<&'ll Metadata>,
17731773
AlignInBits: u32, // (optional; default is 0)
17741774
) -> &'ll Metadata;
1775+
1776+
pub(crate) fn LLVMDIBuilderGetOrCreateSubrange<'ll>(
1777+
Builder: &DIBuilder<'ll>,
1778+
LowerBound: i64,
1779+
Count: i64,
1780+
) -> &'ll Metadata;
17751781
}
17761782

17771783
#[link(name = "llvm-wrapper", kind = "static")]
@@ -2150,12 +2156,6 @@ unsafe extern "C" {
21502156
AlignInBits: u32,
21512157
) -> &'a DIVariable;
21522158

2153-
pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
2154-
Builder: &DIBuilder<'a>,
2155-
Lo: i64,
2156-
Count: i64,
2157-
) -> &'a DISubrange;
2158-
21592159
pub fn LLVMRustDIBuilderGetOrCreateArray<'a>(
21602160
Builder: &DIBuilder<'a>,
21612161
Ptr: *const Option<&'a DIDescriptor>,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,12 +1058,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariable(
10581058
}
10591059
}
10601060

1061-
extern "C" LLVMMetadataRef
1062-
LLVMRustDIBuilderGetOrCreateSubrange(LLVMRustDIBuilderRef Builder, int64_t Lo,
1063-
int64_t Count) {
1064-
return wrap(Builder->getOrCreateSubrange(Lo, Count));
1065-
}
1066-
10671061
extern "C" LLVMMetadataRef
10681062
LLVMRustDIBuilderGetOrCreateArray(LLVMRustDIBuilderRef Builder,
10691063
LLVMMetadataRef *Ptr, unsigned Count) {

0 commit comments

Comments
 (0)