Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8aff664

Browse files
committedFeb 11, 2025·
Clean llvm wrapper
1 parent 8c61cd4 commit 8aff664

File tree

6 files changed

+684
-540
lines changed

6 files changed

+684
-540
lines changed
 

‎compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ mod debuginfo;
7272
mod declare;
7373
mod errors;
7474
mod intrinsic;
75-
// FIXME(Zalathar): Fix all the unreachable-pub warnings that would occur if
76-
// this isn't pub, then make it not pub.
77-
pub mod llvm;
75+
pub(crate) mod llvm;
7876
mod llvm_util;
7977
mod mono_item;
8078
mod type_;

‎compiler/rustc_codegen_llvm/src/llvm/archive_ro.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ use std::{slice, str};
55

66
use rustc_fs_util::path_to_c_string;
77

8-
pub struct ArchiveRO {
8+
pub(crate) struct ArchiveRO {
99
pub raw: &'static mut super::Archive,
1010
}
1111

1212
unsafe impl Send for ArchiveRO {}
1313

14-
pub struct Iter<'a> {
14+
pub(crate) struct Iter<'a> {
1515
raw: &'a mut super::ArchiveIterator<'a>,
1616
}
1717

18-
pub struct Child<'a> {
18+
pub(crate) struct Child<'a> {
1919
pub raw: &'a mut super::ArchiveChild<'a>,
2020
}
2121

@@ -26,7 +26,7 @@ impl ArchiveRO {
2626
///
2727
/// If this archive is used with a mutable method, then an error will be
2828
/// raised.
29-
pub fn open(dst: &Path) -> Result<ArchiveRO, String> {
29+
pub(crate) fn open(dst: &Path) -> Result<ArchiveRO, String> {
3030
unsafe {
3131
let s = path_to_c_string(dst);
3232
let ar = super::LLVMRustOpenArchive(s.as_ptr()).ok_or_else(|| {
@@ -36,7 +36,7 @@ impl ArchiveRO {
3636
}
3737
}
3838

39-
pub fn iter(&self) -> Iter<'_> {
39+
pub(crate) fn iter(&self) -> Iter<'_> {
4040
unsafe { Iter { raw: super::LLVMRustArchiveIteratorNew(self.raw) } }
4141
}
4242
}
@@ -71,7 +71,7 @@ impl<'a> Drop for Iter<'a> {
7171
}
7272

7373
impl<'a> Child<'a> {
74-
pub fn name(&self) -> Option<&'a str> {
74+
pub(crate) fn name(&self) -> Option<&'a str> {
7575
unsafe {
7676
let mut name_len = 0;
7777
let name_ptr = super::LLVMRustArchiveChildName(self.raw, &mut name_len);

‎compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
use libc::c_uint;
44
use rustc_span::InnerSpan;
55

6-
pub use self::Diagnostic::*;
7-
pub use self::OptimizationDiagnosticKind::*;
6+
pub(crate) use self::Diagnostic::*;
7+
pub(crate) use self::OptimizationDiagnosticKind::*;
88
use super::{DiagnosticInfo, SMDiagnostic};
99
use crate::value::Value;
1010

1111
#[derive(Copy, Clone, Debug)]
12-
pub enum OptimizationDiagnosticKind {
12+
pub(crate) enum OptimizationDiagnosticKind {
1313
OptimizationRemark,
1414
OptimizationMissed,
1515
OptimizationAnalysis,
@@ -19,9 +19,10 @@ pub enum OptimizationDiagnosticKind {
1919
OptimizationRemarkOther,
2020
}
2121

22-
pub struct OptimizationDiagnostic<'ll> {
22+
pub(crate) struct OptimizationDiagnostic<'ll> {
2323
pub kind: OptimizationDiagnosticKind,
2424
pub pass_name: String,
25+
#[expect(dead_code)]
2526
pub function: &'ll Value,
2627
pub line: c_uint,
2728
pub column: c_uint,
@@ -73,14 +74,14 @@ impl<'ll> OptimizationDiagnostic<'ll> {
7374
}
7475
}
7576

76-
pub struct SrcMgrDiagnostic {
77+
pub(crate) struct SrcMgrDiagnostic {
7778
pub level: super::DiagnosticLevel,
7879
pub message: String,
7980
pub source: Option<(String, Vec<InnerSpan>)>,
8081
}
8182

8283
impl SrcMgrDiagnostic {
83-
pub unsafe fn unpack(diag: &SMDiagnostic) -> SrcMgrDiagnostic {
84+
pub(crate) unsafe fn unpack(diag: &SMDiagnostic) -> SrcMgrDiagnostic {
8485
// Recover the post-substitution assembly code from LLVM for better
8586
// diagnostics.
8687
let mut have_source = false;
@@ -120,7 +121,7 @@ impl SrcMgrDiagnostic {
120121
}
121122

122123
#[derive(Clone)]
123-
pub struct InlineAsmDiagnostic {
124+
pub(crate) struct InlineAsmDiagnostic {
124125
pub level: super::DiagnosticLevel,
125126
pub cookie: u64,
126127
pub message: String,
@@ -158,19 +159,20 @@ impl InlineAsmDiagnostic {
158159
}
159160
}
160161

161-
pub enum Diagnostic<'ll> {
162+
pub(crate) enum Diagnostic<'ll> {
162163
Optimization(OptimizationDiagnostic<'ll>),
163164
InlineAsm(InlineAsmDiagnostic),
164165
PGO(&'ll DiagnosticInfo),
165166
Linker(&'ll DiagnosticInfo),
166167
Unsupported(&'ll DiagnosticInfo),
167168

168169
/// LLVM has other types that we do not wrap here.
170+
#[expect(dead_code)]
169171
UnknownDiagnostic(&'ll DiagnosticInfo),
170172
}
171173

172174
impl<'ll> Diagnostic<'ll> {
173-
pub unsafe fn unpack(di: &'ll DiagnosticInfo) -> Self {
175+
pub(crate) unsafe fn unpack(di: &'ll DiagnosticInfo) -> Self {
174176
use super::DiagnosticKind as Dk;
175177

176178
unsafe {

‎compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![allow(non_camel_case_types)]
2+
#![expect(dead_code)]
23

34
use libc::{c_char, c_uint};
45

@@ -8,28 +9,28 @@ use crate::llvm::Bool;
89
#[link(name = "llvm-wrapper", kind = "static")]
910
extern "C" {
1011
// Enzyme
11-
pub fn LLVMRustHasMetadata(I: &Value, KindID: c_uint) -> bool;
12-
pub fn LLVMRustEraseInstUntilInclusive(BB: &BasicBlock, I: &Value);
13-
pub fn LLVMRustGetLastInstruction<'a>(BB: &BasicBlock) -> Option<&'a Value>;
14-
pub fn LLVMRustDIGetInstMetadata(I: &Value) -> Option<&Metadata>;
15-
pub fn LLVMRustEraseInstFromParent(V: &Value);
16-
pub fn LLVMRustGetTerminator<'a>(B: &BasicBlock) -> &'a Value;
17-
pub fn LLVMRustVerifyFunction(V: &Value, action: LLVMRustVerifierFailureAction) -> Bool;
12+
pub(crate) fn LLVMRustHasMetadata(I: &Value, KindID: c_uint) -> bool;
13+
pub(crate) fn LLVMRustEraseInstUntilInclusive(BB: &BasicBlock, I: &Value);
14+
pub(crate) fn LLVMRustGetLastInstruction<'a>(BB: &BasicBlock) -> Option<&'a Value>;
15+
pub(crate) fn LLVMRustDIGetInstMetadata(I: &Value) -> Option<&Metadata>;
16+
pub(crate) fn LLVMRustEraseInstFromParent(V: &Value);
17+
pub(crate) fn LLVMRustGetTerminator<'a>(B: &BasicBlock) -> &'a Value;
18+
pub(crate) fn LLVMRustVerifyFunction(V: &Value, action: LLVMRustVerifierFailureAction) -> Bool;
1819
}
1920

2021
extern "C" {
2122
// Enzyme
22-
pub fn LLVMDumpModule(M: &Module);
23-
pub fn LLVMDumpValue(V: &Value);
24-
pub fn LLVMGetFunctionCallConv(F: &Value) -> c_uint;
25-
pub fn LLVMGetReturnType(T: &Type) -> &Type;
26-
pub fn LLVMGetParams(Fnc: &Value, parms: *mut &Value);
27-
pub fn LLVMGetNamedFunction(M: &Module, Name: *const c_char) -> Option<&Value>;
23+
pub(crate) fn LLVMDumpModule(M: &Module);
24+
pub(crate) fn LLVMDumpValue(V: &Value);
25+
pub(crate) fn LLVMGetFunctionCallConv(F: &Value) -> c_uint;
26+
pub(crate) fn LLVMGetReturnType(T: &Type) -> &Type;
27+
pub(crate) fn LLVMGetParams(Fnc: &Value, parms: *mut &Value);
28+
pub(crate) fn LLVMGetNamedFunction(M: &Module, Name: *const c_char) -> Option<&Value>;
2829
}
2930

3031
#[repr(C)]
3132
#[derive(Copy, Clone, PartialEq)]
32-
pub enum LLVMRustVerifierFailureAction {
33+
pub(crate) enum LLVMRustVerifierFailureAction {
3334
LLVMAbortProcessAction = 0,
3435
LLVMPrintMessageAction = 1,
3536
LLVMReturnStatusAction = 2,

‎compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 594 additions & 459 deletions
Large diffs are not rendered by default.

‎compiler/rustc_codegen_llvm/src/llvm/mod.rs

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,39 @@ use libc::c_uint;
1010
use rustc_abi::{Align, Size, WrappingRange};
1111
use rustc_llvm::RustString;
1212

13-
pub use self::CallConv::*;
14-
pub use self::CodeGenOptSize::*;
15-
pub use self::MetadataType::*;
16-
pub use self::ffi::*;
13+
pub(crate) use self::CallConv::*;
14+
pub(crate) use self::CodeGenOptSize::*;
15+
pub(crate) use self::MetadataType::*;
16+
pub(crate) use self::ffi::*;
1717
use crate::common::AsCCharPtr;
1818

19-
pub mod archive_ro;
20-
pub mod diagnostic;
21-
pub mod enzyme_ffi;
19+
pub(crate) mod archive_ro;
20+
pub(crate) mod diagnostic;
21+
pub(crate) mod enzyme_ffi;
2222
mod ffi;
2323

24-
pub use self::enzyme_ffi::*;
24+
pub(crate) use self::enzyme_ffi::*;
2525

2626
impl LLVMRustResult {
27-
pub fn into_result(self) -> Result<(), ()> {
27+
pub(crate) fn into_result(self) -> Result<(), ()> {
2828
match self {
2929
LLVMRustResult::Success => Ok(()),
3030
LLVMRustResult::Failure => Err(()),
3131
}
3232
}
3333
}
3434

35-
pub fn AddFunctionAttributes<'ll>(llfn: &'ll Value, idx: AttributePlace, attrs: &[&'ll Attribute]) {
35+
pub(crate) fn AddFunctionAttributes<'ll>(
36+
llfn: &'ll Value,
37+
idx: AttributePlace,
38+
attrs: &[&'ll Attribute],
39+
) {
3640
unsafe {
3741
LLVMRustAddFunctionAttributes(llfn, idx.as_uint(), attrs.as_ptr(), attrs.len());
3842
}
3943
}
4044

41-
pub fn AddCallSiteAttributes<'ll>(
45+
pub(crate) fn AddCallSiteAttributes<'ll>(
4246
callsite: &'ll Value,
4347
idx: AttributePlace,
4448
attrs: &[&'ll Attribute],
@@ -48,7 +52,11 @@ pub fn AddCallSiteAttributes<'ll>(
4852
}
4953
}
5054

51-
pub fn CreateAttrStringValue<'ll>(llcx: &'ll Context, attr: &str, value: &str) -> &'ll Attribute {
55+
pub(crate) fn CreateAttrStringValue<'ll>(
56+
llcx: &'ll Context,
57+
attr: &str,
58+
value: &str,
59+
) -> &'ll Attribute {
5260
unsafe {
5361
LLVMCreateStringAttribute(
5462
llcx,
@@ -60,7 +68,7 @@ pub fn CreateAttrStringValue<'ll>(llcx: &'ll Context, attr: &str, value: &str) -
6068
}
6169
}
6270

63-
pub fn CreateAttrString<'ll>(llcx: &'ll Context, attr: &str) -> &'ll Attribute {
71+
pub(crate) fn CreateAttrString<'ll>(llcx: &'ll Context, attr: &str) -> &'ll Attribute {
6472
unsafe {
6573
LLVMCreateStringAttribute(
6674
llcx,
@@ -72,39 +80,39 @@ pub fn CreateAttrString<'ll>(llcx: &'ll Context, attr: &str) -> &'ll Attribute {
7280
}
7381
}
7482

75-
pub fn CreateAlignmentAttr(llcx: &Context, bytes: u64) -> &Attribute {
83+
pub(crate) fn CreateAlignmentAttr(llcx: &Context, bytes: u64) -> &Attribute {
7684
unsafe { LLVMRustCreateAlignmentAttr(llcx, bytes) }
7785
}
7886

79-
pub fn CreateDereferenceableAttr(llcx: &Context, bytes: u64) -> &Attribute {
87+
pub(crate) fn CreateDereferenceableAttr(llcx: &Context, bytes: u64) -> &Attribute {
8088
unsafe { LLVMRustCreateDereferenceableAttr(llcx, bytes) }
8189
}
8290

83-
pub fn CreateDereferenceableOrNullAttr(llcx: &Context, bytes: u64) -> &Attribute {
91+
pub(crate) fn CreateDereferenceableOrNullAttr(llcx: &Context, bytes: u64) -> &Attribute {
8492
unsafe { LLVMRustCreateDereferenceableOrNullAttr(llcx, bytes) }
8593
}
8694

87-
pub fn CreateByValAttr<'ll>(llcx: &'ll Context, ty: &'ll Type) -> &'ll Attribute {
95+
pub(crate) fn CreateByValAttr<'ll>(llcx: &'ll Context, ty: &'ll Type) -> &'ll Attribute {
8896
unsafe { LLVMRustCreateByValAttr(llcx, ty) }
8997
}
9098

91-
pub fn CreateStructRetAttr<'ll>(llcx: &'ll Context, ty: &'ll Type) -> &'ll Attribute {
99+
pub(crate) fn CreateStructRetAttr<'ll>(llcx: &'ll Context, ty: &'ll Type) -> &'ll Attribute {
92100
unsafe { LLVMRustCreateStructRetAttr(llcx, ty) }
93101
}
94102

95-
pub fn CreateUWTableAttr(llcx: &Context, async_: bool) -> &Attribute {
103+
pub(crate) fn CreateUWTableAttr(llcx: &Context, async_: bool) -> &Attribute {
96104
unsafe { LLVMRustCreateUWTableAttr(llcx, async_) }
97105
}
98106

99-
pub fn CreateAllocSizeAttr(llcx: &Context, size_arg: u32) -> &Attribute {
107+
pub(crate) fn CreateAllocSizeAttr(llcx: &Context, size_arg: u32) -> &Attribute {
100108
unsafe { LLVMRustCreateAllocSizeAttr(llcx, size_arg) }
101109
}
102110

103-
pub fn CreateAllocKindAttr(llcx: &Context, kind_arg: AllocKindFlags) -> &Attribute {
111+
pub(crate) fn CreateAllocKindAttr(llcx: &Context, kind_arg: AllocKindFlags) -> &Attribute {
104112
unsafe { LLVMRustCreateAllocKindAttr(llcx, kind_arg.bits()) }
105113
}
106114

107-
pub fn CreateRangeAttr(llcx: &Context, size: Size, range: WrappingRange) -> &Attribute {
115+
pub(crate) fn CreateRangeAttr(llcx: &Context, size: Size, range: WrappingRange) -> &Attribute {
108116
let lower = range.start;
109117
let upper = range.end.wrapping_add(1);
110118
let lower_words = [lower as u64, (lower >> 64) as u64];
@@ -120,14 +128,14 @@ pub fn CreateRangeAttr(llcx: &Context, size: Size, range: WrappingRange) -> &Att
120128
}
121129

122130
#[derive(Copy, Clone)]
123-
pub enum AttributePlace {
131+
pub(crate) enum AttributePlace {
124132
ReturnValue,
125133
Argument(u32),
126134
Function,
127135
}
128136

129137
impl AttributePlace {
130-
pub fn as_uint(self) -> c_uint {
138+
pub(crate) fn as_uint(self) -> c_uint {
131139
match self {
132140
AttributePlace::ReturnValue => 0,
133141
AttributePlace::Argument(i) => 1 + i,
@@ -138,7 +146,7 @@ impl AttributePlace {
138146

139147
#[derive(Copy, Clone, PartialEq)]
140148
#[repr(C)]
141-
pub enum CodeGenOptSize {
149+
pub(crate) enum CodeGenOptSize {
142150
CodeGenOptSizeNone = 0,
143151
CodeGenOptSizeDefault = 1,
144152
CodeGenOptSizeAggressive = 2,
@@ -159,12 +167,12 @@ impl FromStr for ArchiveKind {
159167
}
160168
}
161169

162-
pub fn SetInstructionCallConv(instr: &Value, cc: CallConv) {
170+
pub(crate) fn SetInstructionCallConv(instr: &Value, cc: CallConv) {
163171
unsafe {
164172
LLVMSetInstructionCallConv(instr, cc as c_uint);
165173
}
166174
}
167-
pub fn SetFunctionCallConv(fn_: &Value, cc: CallConv) {
175+
pub(crate) fn SetFunctionCallConv(fn_: &Value, cc: CallConv) {
168176
unsafe {
169177
LLVMSetFunctionCallConv(fn_, cc as c_uint);
170178
}
@@ -176,82 +184,82 @@ pub fn SetFunctionCallConv(fn_: &Value, cc: CallConv) {
176184
// value's name as the comdat value to make sure that it is in a 1-to-1 relationship to the
177185
// function.
178186
// For more details on COMDAT sections see e.g., https://www.airs.com/blog/archives/52
179-
pub fn SetUniqueComdat(llmod: &Module, val: &Value) {
187+
pub(crate) fn SetUniqueComdat(llmod: &Module, val: &Value) {
180188
let name_buf = get_value_name(val).to_vec();
181189
let name =
182190
CString::from_vec_with_nul(name_buf).or_else(|buf| CString::new(buf.into_bytes())).unwrap();
183191
set_comdat(llmod, val, &name);
184192
}
185193

186-
pub fn SetUnnamedAddress(global: &Value, unnamed: UnnamedAddr) {
194+
pub(crate) fn SetUnnamedAddress(global: &Value, unnamed: UnnamedAddr) {
187195
unsafe {
188196
LLVMSetUnnamedAddress(global, unnamed);
189197
}
190198
}
191199

192-
pub fn set_thread_local_mode(global: &Value, mode: ThreadLocalMode) {
200+
pub(crate) fn set_thread_local_mode(global: &Value, mode: ThreadLocalMode) {
193201
unsafe {
194202
LLVMSetThreadLocalMode(global, mode);
195203
}
196204
}
197205

198206
impl AttributeKind {
199207
/// Create an LLVM Attribute with no associated value.
200-
pub fn create_attr(self, llcx: &Context) -> &Attribute {
208+
pub(crate) fn create_attr(self, llcx: &Context) -> &Attribute {
201209
unsafe { LLVMRustCreateAttrNoValue(llcx, self) }
202210
}
203211
}
204212

205213
impl MemoryEffects {
206214
/// Create an LLVM Attribute with these memory effects.
207-
pub fn create_attr(self, llcx: &Context) -> &Attribute {
215+
pub(crate) fn create_attr(self, llcx: &Context) -> &Attribute {
208216
unsafe { LLVMRustCreateMemoryEffectsAttr(llcx, self) }
209217
}
210218
}
211219

212-
pub fn set_section(llglobal: &Value, section_name: &CStr) {
220+
pub(crate) fn set_section(llglobal: &Value, section_name: &CStr) {
213221
unsafe {
214222
LLVMSetSection(llglobal, section_name.as_ptr());
215223
}
216224
}
217225

218-
pub fn add_global<'a>(llmod: &'a Module, ty: &'a Type, name_cstr: &CStr) -> &'a Value {
226+
pub(crate) fn add_global<'a>(llmod: &'a Module, ty: &'a Type, name_cstr: &CStr) -> &'a Value {
219227
unsafe { LLVMAddGlobal(llmod, ty, name_cstr.as_ptr()) }
220228
}
221229

222-
pub fn set_initializer(llglobal: &Value, constant_val: &Value) {
230+
pub(crate) fn set_initializer(llglobal: &Value, constant_val: &Value) {
223231
unsafe {
224232
LLVMSetInitializer(llglobal, constant_val);
225233
}
226234
}
227235

228-
pub fn set_global_constant(llglobal: &Value, is_constant: bool) {
236+
pub(crate) fn set_global_constant(llglobal: &Value, is_constant: bool) {
229237
unsafe {
230238
LLVMSetGlobalConstant(llglobal, if is_constant { ffi::True } else { ffi::False });
231239
}
232240
}
233241

234-
pub fn get_linkage(llglobal: &Value) -> Linkage {
242+
pub(crate) fn get_linkage(llglobal: &Value) -> Linkage {
235243
unsafe { LLVMGetLinkage(llglobal) }.to_rust()
236244
}
237245

238-
pub fn set_linkage(llglobal: &Value, linkage: Linkage) {
246+
pub(crate) fn set_linkage(llglobal: &Value, linkage: Linkage) {
239247
unsafe {
240248
LLVMSetLinkage(llglobal, linkage);
241249
}
242250
}
243251

244-
pub fn get_visibility(llglobal: &Value) -> Visibility {
252+
pub(crate) fn get_visibility(llglobal: &Value) -> Visibility {
245253
unsafe { LLVMGetVisibility(llglobal) }.to_rust()
246254
}
247255

248-
pub fn set_visibility(llglobal: &Value, visibility: Visibility) {
256+
pub(crate) fn set_visibility(llglobal: &Value, visibility: Visibility) {
249257
unsafe {
250258
LLVMSetVisibility(llglobal, visibility);
251259
}
252260
}
253261

254-
pub fn set_alignment(llglobal: &Value, align: Align) {
262+
pub(crate) fn set_alignment(llglobal: &Value, align: Align) {
255263
unsafe {
256264
ffi::LLVMSetAlignment(llglobal, align.bytes() as c_uint);
257265
}
@@ -261,15 +269,15 @@ pub fn set_alignment(llglobal: &Value, align: Align) {
261269
///
262270
/// Inserts the comdat into `llmod` if it does not exist.
263271
/// It is an error to call this if the target does not support comdat.
264-
pub fn set_comdat(llmod: &Module, llglobal: &Value, name: &CStr) {
272+
pub(crate) fn set_comdat(llmod: &Module, llglobal: &Value, name: &CStr) {
265273
unsafe {
266274
let comdat = LLVMGetOrInsertComdat(llmod, name.as_ptr());
267275
LLVMSetComdat(llglobal, comdat);
268276
}
269277
}
270278

271279
/// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
272-
pub fn get_param(llfn: &Value, index: c_uint) -> &Value {
280+
pub(crate) fn get_param(llfn: &Value, index: c_uint) -> &Value {
273281
unsafe {
274282
assert!(
275283
index < LLVMCountParams(llfn),
@@ -282,7 +290,7 @@ pub fn get_param(llfn: &Value, index: c_uint) -> &Value {
282290
}
283291

284292
/// Safe wrapper for `LLVMGetValueName2` into a byte slice
285-
pub fn get_value_name(value: &Value) -> &[u8] {
293+
pub(crate) fn get_value_name(value: &Value) -> &[u8] {
286294
unsafe {
287295
let mut len = 0;
288296
let data = LLVMGetValueName2(value, &mut len);
@@ -291,28 +299,28 @@ pub fn get_value_name(value: &Value) -> &[u8] {
291299
}
292300

293301
/// Safe wrapper for `LLVMSetValueName2` from a byte slice
294-
pub fn set_value_name(value: &Value, name: &[u8]) {
302+
pub(crate) fn set_value_name(value: &Value, name: &[u8]) {
295303
unsafe {
296304
let data = name.as_c_char_ptr();
297305
LLVMSetValueName2(value, data, name.len());
298306
}
299307
}
300308

301-
pub fn build_string(f: impl FnOnce(&RustString)) -> Result<String, FromUtf8Error> {
309+
pub(crate) fn build_string(f: impl FnOnce(&RustString)) -> Result<String, FromUtf8Error> {
302310
String::from_utf8(RustString::build_byte_buffer(f))
303311
}
304312

305-
pub fn build_byte_buffer(f: impl FnOnce(&RustString)) -> Vec<u8> {
313+
pub(crate) fn build_byte_buffer(f: impl FnOnce(&RustString)) -> Vec<u8> {
306314
RustString::build_byte_buffer(f)
307315
}
308316

309-
pub fn twine_to_string(tr: &Twine) -> String {
317+
pub(crate) fn twine_to_string(tr: &Twine) -> String {
310318
unsafe {
311319
build_string(|s| LLVMRustWriteTwineToString(tr, s)).expect("got a non-UTF8 Twine from LLVM")
312320
}
313321
}
314322

315-
pub fn last_error() -> Option<String> {
323+
pub(crate) fn last_error() -> Option<String> {
316324
unsafe {
317325
let cstr = LLVMRustGetLastError();
318326
if cstr.is_null() {

0 commit comments

Comments
 (0)
Please sign in to comment.