Skip to content

Commit 5bf2edb

Browse files
committed
Clean llvm wrapper
1 parent 617aad8 commit 5bf2edb

File tree

6 files changed

+142
-134
lines changed

6 files changed

+142
-134
lines changed

Diff for: compiler/rustc_codegen_llvm/src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use std::mem::ManuallyDrop;
3030
use back::owned_target_machine::OwnedTargetMachine;
3131
use back::write::{create_informational_target_machine, create_target_machine};
3232
use errors::{AutoDiffWithoutLTO, ParseTargetMachineConfig};
33-
pub(crate) use llvm_util::target_features_cfg;
33+
use llvm_util::target_features_cfg;
3434
use rustc_ast::expand::allocator::AllocatorKind;
3535
use rustc_ast::expand::autodiff_attrs::AutoDiffItem;
3636
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
@@ -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+
mod llvm;
7876
mod llvm_util;
7977
mod mono_item;
8078
mod type_;

Diff for: compiler/rustc_codegen_llvm/src/llvm/archive_ro.rs

+3-3
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

Diff for: compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs

+11-9
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+
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 {

Diff for: compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ unsafe extern "C" {
3030

3131
#[repr(C)]
3232
#[derive(Copy, Clone, PartialEq)]
33-
pub enum LLVMRustVerifierFailureAction {
33+
pub(crate) enum LLVMRustVerifierFailureAction {
3434
LLVMAbortProcessAction = 0,
3535
LLVMPrintMessageAction = 1,
3636
LLVMReturnStatusAction = 2,
3737
}
3838

3939
#[cfg(llvm_enzyme)]
40-
pub use self::Enzyme_AD::*;
40+
pub(crate) use self::Enzyme_AD::*;
4141

4242
#[cfg(llvm_enzyme)]
43-
pub mod Enzyme_AD {
43+
pub(crate) mod Enzyme_AD {
4444
use libc::c_void;
4545
extern "C" {
46-
pub fn EnzymeSetCLBool(arg1: *mut ::std::os::raw::c_void, arg2: u8);
46+
pub(crate) fn EnzymeSetCLBool(arg1: *mut ::std::os::raw::c_void, arg2: u8);
4747
}
4848
extern "C" {
4949
static mut EnzymePrintPerf: c_void;
@@ -55,77 +55,77 @@ pub mod Enzyme_AD {
5555
static mut EnzymeInline: c_void;
5656
static mut RustTypeRules: c_void;
5757
}
58-
pub fn set_print_perf(print: bool) {
58+
pub(crate) fn set_print_perf(print: bool) {
5959
unsafe {
6060
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintPerf), print as u8);
6161
}
6262
}
63-
pub fn set_print_activity(print: bool) {
63+
pub(crate) fn set_print_activity(print: bool) {
6464
unsafe {
6565
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintActivity), print as u8);
6666
}
6767
}
68-
pub fn set_print_type(print: bool) {
68+
pub(crate) fn set_print_type(print: bool) {
6969
unsafe {
7070
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintType), print as u8);
7171
}
7272
}
73-
pub fn set_print(print: bool) {
73+
pub(crate) fn set_print(print: bool) {
7474
unsafe {
7575
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrint), print as u8);
7676
}
7777
}
78-
pub fn set_strict_aliasing(strict: bool) {
78+
pub(crate) fn set_strict_aliasing(strict: bool) {
7979
unsafe {
8080
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymeStrictAliasing), strict as u8);
8181
}
8282
}
83-
pub fn set_loose_types(loose: bool) {
83+
pub(crate) fn set_loose_types(loose: bool) {
8484
unsafe {
8585
EnzymeSetCLBool(std::ptr::addr_of_mut!(looseTypeAnalysis), loose as u8);
8686
}
8787
}
88-
pub fn set_inline(val: bool) {
88+
pub(crate) fn set_inline(val: bool) {
8989
unsafe {
9090
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymeInline), val as u8);
9191
}
9292
}
93-
pub fn set_rust_rules(val: bool) {
93+
pub(crate) fn set_rust_rules(val: bool) {
9494
unsafe {
9595
EnzymeSetCLBool(std::ptr::addr_of_mut!(RustTypeRules), val as u8);
9696
}
9797
}
9898
}
9999

100100
#[cfg(not(llvm_enzyme))]
101-
pub use self::Fallback_AD::*;
101+
pub(crate) use self::Fallback_AD::*;
102102

103103
#[cfg(not(llvm_enzyme))]
104-
pub mod Fallback_AD {
104+
pub(crate) mod Fallback_AD {
105105
#![allow(unused_variables)]
106106

107-
pub fn set_inline(val: bool) {
107+
pub(crate) fn set_inline(val: bool) {
108108
unimplemented!()
109109
}
110-
pub fn set_print_perf(print: bool) {
110+
pub(crate) fn set_print_perf(print: bool) {
111111
unimplemented!()
112112
}
113-
pub fn set_print_activity(print: bool) {
113+
pub(crate) fn set_print_activity(print: bool) {
114114
unimplemented!()
115115
}
116-
pub fn set_print_type(print: bool) {
116+
pub(crate) fn set_print_type(print: bool) {
117117
unimplemented!()
118118
}
119-
pub fn set_print(print: bool) {
119+
pub(crate) fn set_print(print: bool) {
120120
unimplemented!()
121121
}
122-
pub fn set_strict_aliasing(strict: bool) {
122+
pub(crate) fn set_strict_aliasing(strict: bool) {
123123
unimplemented!()
124124
}
125-
pub fn set_loose_types(loose: bool) {
125+
pub(crate) fn set_loose_types(loose: bool) {
126126
unimplemented!()
127127
}
128-
pub fn set_rust_rules(val: bool) {
128+
pub(crate) fn set_rust_rules(val: bool) {
129129
unimplemented!()
130130
}
131131
}

0 commit comments

Comments
 (0)