Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead code from rustc_codegen_llvm and the LLVM wrapper #136653

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,6 @@ pub enum LLVMRustResult {
Failure,
}

/// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h.
///
/// We include only architectures supported on Windows.
#[derive(Copy, Clone, PartialEq)]
#[repr(C)]
pub enum LLVMMachineType {
AMD64 = 0x8664,
I386 = 0x14c,
ARM64 = 0xaa64,
ARM64EC = 0xa641,
ARM = 0x01c0,
}
Comment on lines -77 to -83
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historical note: It looks like we used to pass this to LLVM code for emitting import libraries on Windows, and it probably became unnecessary after #129164. Good to remove.


/// Must match the layout of `LLVMRustModuleFlagMergeBehavior`.
///
/// When merging modules (e.g. during LTO), their metadata flags are combined. Conflicts are
Expand Down Expand Up @@ -645,16 +632,6 @@ pub enum ThreadLocalMode {
LocalExec,
}

/// LLVMRustTailCallKind
#[derive(Copy, Clone)]
#[repr(C)]
pub enum TailCallKind {
None,
Tail,
MustTail,
NoTail,
}
Comment on lines -651 to -656
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: This removal was justified in #135502 (comment), so good to remove.


/// LLVMRustChecksumKind
#[derive(Copy, Clone)]
#[repr(C)]
Expand Down Expand Up @@ -773,7 +750,6 @@ pub struct Builder<'a>(InvariantOpaque<'a>);
#[repr(C)]
pub struct PassManager<'a>(InvariantOpaque<'a>);
unsafe extern "C" {
pub type Pass;
pub type TargetMachine;
pub type Archive;
}
Expand All @@ -799,7 +775,6 @@ unsafe extern "C" {
}

pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historical note: Looks like this became unused in #100460.


pub mod debuginfo {
use std::ptr;
Expand Down Expand Up @@ -853,7 +828,6 @@ pub mod debuginfo {
pub type DIFile = DIScope;
pub type DILexicalBlock = DIScope;
pub type DISubprogram = DIScope;
pub type DINameSpace = DIScope;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historical note: This became unused in #136375.

pub type DIType = DIDescriptor;
pub type DIBasicType = DIType;
pub type DIDerivedType = DIType;
Expand Down Expand Up @@ -1809,7 +1783,6 @@ unsafe extern "C" {
Name: *const c_char,
NameLen: size_t,
) -> Option<&Value>;
pub fn LLVMRustSetTailCallKind(CallInst: &Value, TKC: TailCallKind);

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

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

pub fn LLVMRustIsBitcode(ptr: *const u8, len: usize) -> bool;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historical note: This became unused in 9de0d14.


pub fn LLVMRustLLVMHasZlibCompressionForDebugSymbols() -> bool;

pub fn LLVMRustLLVMHasZstdCompressionForDebugSymbols() -> bool;
Expand Down
31 changes: 0 additions & 31 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,33 +195,6 @@ LLVMRustVerifyFunction(LLVMValueRef Fn, LLVMRustVerifierFailureAction Action) {
return LLVMVerifyFunction(Fn, fromRust(Action));
}

enum class LLVMRustTailCallKind {
None,
Tail,
MustTail,
NoTail,
};

static CallInst::TailCallKind fromRust(LLVMRustTailCallKind Kind) {
switch (Kind) {
case LLVMRustTailCallKind::None:
return CallInst::TailCallKind::TCK_None;
case LLVMRustTailCallKind::Tail:
return CallInst::TailCallKind::TCK_Tail;
case LLVMRustTailCallKind::MustTail:
return CallInst::TailCallKind::TCK_MustTail;
case LLVMRustTailCallKind::NoTail:
return CallInst::TailCallKind::TCK_NoTail;
default:
report_fatal_error("bad CallInst::TailCallKind.");
}
}

extern "C" void LLVMRustSetTailCallKind(LLVMValueRef Call,
LLVMRustTailCallKind TCK) {
unwrap<CallInst>(Call)->setTailCallKind(fromRust(TCK));
}

extern "C" LLVMValueRef LLVMRustGetOrInsertFunction(LLVMModuleRef M,
const char *Name,
size_t NameLen,
Expand Down Expand Up @@ -1976,10 +1949,6 @@ extern "C" int32_t LLVMRustGetElementTypeArgIndex(LLVMValueRef CallSite) {
return -1;
}

extern "C" bool LLVMRustIsBitcode(char *ptr, size_t len) {
return identify_magic(StringRef(ptr, len)) == file_magic::bitcode;
}

extern "C" bool LLVMRustIsNonGVFunctionPointerTy(LLVMValueRef V) {
if (unwrap<Value>(V)->getType()->isPointerTy()) {
if (auto *GV = dyn_cast<GlobalValue>(unwrap<Value>(V))) {
Expand Down
Loading