Skip to content

Commit 73d5478

Browse files
committed
Remove dead code from rustc_codegen_llvm and the LLVM wrapper
1 parent 79f82ad commit 73d5478

File tree

4 files changed

+7
-70
lines changed

4 files changed

+7
-70
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void
493493
.expect("non-UTF8 diagnostic");
494494
dcx.emit_err(FromLlvmDiag { message });
495495
}
496-
llvm::diagnostic::UnknownDiagnostic(..) => {}
496+
llvm::diagnostic::UnknownDiagnostic => {}
497497
}
498498
}
499499

compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_span::InnerSpan;
66
pub use self::Diagnostic::*;
77
pub use self::OptimizationDiagnosticKind::*;
88
use super::{DiagnosticInfo, SMDiagnostic};
9-
use crate::value::Value;
109

1110
#[derive(Copy, Clone, Debug)]
1211
pub enum OptimizationDiagnosticKind {
@@ -19,18 +18,17 @@ pub enum OptimizationDiagnosticKind {
1918
OptimizationRemarkOther,
2019
}
2120

22-
pub struct OptimizationDiagnostic<'ll> {
21+
pub struct OptimizationDiagnostic {
2322
pub kind: OptimizationDiagnosticKind,
2423
pub pass_name: String,
25-
pub function: &'ll Value,
2624
pub line: c_uint,
2725
pub column: c_uint,
2826
pub filename: String,
2927
pub message: String,
3028
}
3129

32-
impl<'ll> OptimizationDiagnostic<'ll> {
33-
unsafe fn unpack(kind: OptimizationDiagnosticKind, di: &'ll DiagnosticInfo) -> Self {
30+
impl OptimizationDiagnostic {
31+
unsafe fn unpack(kind: OptimizationDiagnosticKind, di: &DiagnosticInfo) -> Self {
3432
let mut function = None;
3533
let mut line = 0;
3634
let mut column = 0;
@@ -64,7 +62,6 @@ impl<'ll> OptimizationDiagnostic<'ll> {
6462
OptimizationDiagnostic {
6563
kind,
6664
pass_name: pass_name.expect("got a non-UTF8 pass name from LLVM"),
67-
function: function.unwrap(),
6865
line,
6966
column,
7067
filename,
@@ -159,14 +156,14 @@ impl InlineAsmDiagnostic {
159156
}
160157

161158
pub enum Diagnostic<'ll> {
162-
Optimization(OptimizationDiagnostic<'ll>),
159+
Optimization(OptimizationDiagnostic),
163160
InlineAsm(InlineAsmDiagnostic),
164161
PGO(&'ll DiagnosticInfo),
165162
Linker(&'ll DiagnosticInfo),
166163
Unsupported(&'ll DiagnosticInfo),
167164

168165
/// LLVM has other types that we do not wrap here.
169-
UnknownDiagnostic(&'ll DiagnosticInfo),
166+
UnknownDiagnostic,
170167
}
171168

172169
impl<'ll> Diagnostic<'ll> {
@@ -210,7 +207,7 @@ impl<'ll> Diagnostic<'ll> {
210207

211208
Dk::SrcMgr => InlineAsm(InlineAsmDiagnostic::unpackSrcMgr(di)),
212209

213-
_ => UnknownDiagnostic(di),
210+
_ => UnknownDiagnostic,
214211
}
215212
}
216213
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,6 @@ pub enum LLVMRustResult {
6969
Failure,
7070
}
7171

72-
/// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h.
73-
///
74-
/// We include only architectures supported on Windows.
75-
#[derive(Copy, Clone, PartialEq)]
76-
#[repr(C)]
77-
pub enum LLVMMachineType {
78-
AMD64 = 0x8664,
79-
I386 = 0x14c,
80-
ARM64 = 0xaa64,
81-
ARM64EC = 0xa641,
82-
ARM = 0x01c0,
83-
}
84-
8572
/// Must match the layout of `LLVMRustModuleFlagMergeBehavior`.
8673
///
8774
/// When merging modules (e.g. during LTO), their metadata flags are combined. Conflicts are
@@ -645,16 +632,6 @@ pub enum ThreadLocalMode {
645632
LocalExec,
646633
}
647634

648-
/// LLVMRustTailCallKind
649-
#[derive(Copy, Clone)]
650-
#[repr(C)]
651-
pub enum TailCallKind {
652-
None,
653-
Tail,
654-
MustTail,
655-
NoTail,
656-
}
657-
658635
/// LLVMRustChecksumKind
659636
#[derive(Copy, Clone)]
660637
#[repr(C)]
@@ -773,7 +750,6 @@ pub struct Builder<'a>(InvariantOpaque<'a>);
773750
#[repr(C)]
774751
pub struct PassManager<'a>(InvariantOpaque<'a>);
775752
unsafe extern "C" {
776-
pub type Pass;
777753
pub type TargetMachine;
778754
pub type Archive;
779755
}
@@ -799,7 +775,6 @@ unsafe extern "C" {
799775
}
800776

801777
pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
802-
pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
803778

804779
pub mod debuginfo {
805780
use std::ptr;
@@ -853,7 +828,6 @@ pub mod debuginfo {
853828
pub type DIFile = DIScope;
854829
pub type DILexicalBlock = DIScope;
855830
pub type DISubprogram = DIScope;
856-
pub type DINameSpace = DIScope;
857831
pub type DIType = DIDescriptor;
858832
pub type DIBasicType = DIType;
859833
pub type DIDerivedType = DIType;
@@ -1809,7 +1783,6 @@ unsafe extern "C" {
18091783
Name: *const c_char,
18101784
NameLen: size_t,
18111785
) -> Option<&Value>;
1812-
pub fn LLVMRustSetTailCallKind(CallInst: &Value, TKC: TailCallKind);
18131786

18141787
// Operations on attributes
18151788
pub fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute;
@@ -2586,8 +2559,6 @@ unsafe extern "C" {
25862559

25872560
pub fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32;
25882561

2589-
pub fn LLVMRustIsBitcode(ptr: *const u8, len: usize) -> bool;
2590-
25912562
pub fn LLVMRustLLVMHasZlibCompressionForDebugSymbols() -> bool;
25922563

25932564
pub fn LLVMRustLLVMHasZstdCompressionForDebugSymbols() -> bool;

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -195,33 +195,6 @@ LLVMRustVerifyFunction(LLVMValueRef Fn, LLVMRustVerifierFailureAction Action) {
195195
return LLVMVerifyFunction(Fn, fromRust(Action));
196196
}
197197

198-
enum class LLVMRustTailCallKind {
199-
None,
200-
Tail,
201-
MustTail,
202-
NoTail,
203-
};
204-
205-
static CallInst::TailCallKind fromRust(LLVMRustTailCallKind Kind) {
206-
switch (Kind) {
207-
case LLVMRustTailCallKind::None:
208-
return CallInst::TailCallKind::TCK_None;
209-
case LLVMRustTailCallKind::Tail:
210-
return CallInst::TailCallKind::TCK_Tail;
211-
case LLVMRustTailCallKind::MustTail:
212-
return CallInst::TailCallKind::TCK_MustTail;
213-
case LLVMRustTailCallKind::NoTail:
214-
return CallInst::TailCallKind::TCK_NoTail;
215-
default:
216-
report_fatal_error("bad CallInst::TailCallKind.");
217-
}
218-
}
219-
220-
extern "C" void LLVMRustSetTailCallKind(LLVMValueRef Call,
221-
LLVMRustTailCallKind TCK) {
222-
unwrap<CallInst>(Call)->setTailCallKind(fromRust(TCK));
223-
}
224-
225198
extern "C" LLVMValueRef LLVMRustGetOrInsertFunction(LLVMModuleRef M,
226199
const char *Name,
227200
size_t NameLen,
@@ -1976,10 +1949,6 @@ extern "C" int32_t LLVMRustGetElementTypeArgIndex(LLVMValueRef CallSite) {
19761949
return -1;
19771950
}
19781951

1979-
extern "C" bool LLVMRustIsBitcode(char *ptr, size_t len) {
1980-
return identify_magic(StringRef(ptr, len)) == file_magic::bitcode;
1981-
}
1982-
19831952
extern "C" bool LLVMRustIsNonGVFunctionPointerTy(LLVMValueRef V) {
19841953
if (unwrap<Value>(V)->getType()->isPointerTy()) {
19851954
if (auto *GV = dyn_cast<GlobalValue>(unwrap<Value>(V))) {

0 commit comments

Comments
 (0)