Skip to content

Commit 017e172

Browse files
committed
Remove dead code from cg_llvm
1 parent b629c85 commit 017e172

File tree

5 files changed

+0
-100
lines changed

5 files changed

+0
-100
lines changed

compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs

-13
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@ pub enum OptimizationDiagnosticKind {
2020
OptimizationRemarkOther,
2121
}
2222

23-
impl OptimizationDiagnosticKind {
24-
pub fn describe(self) -> &'static str {
25-
match self {
26-
OptimizationRemark | OptimizationRemarkOther => "remark",
27-
OptimizationMissed => "missed",
28-
OptimizationAnalysis => "analysis",
29-
OptimizationAnalysisFPCommute => "floating-point",
30-
OptimizationAnalysisAliasing => "aliasing",
31-
OptimizationFailure => "failure",
32-
}
33-
}
34-
}
35-
3623
pub struct OptimizationDiagnostic<'ll> {
3724
pub kind: OptimizationDiagnosticKind,
3825
pub pass_name: String,

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-27
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,6 @@ pub enum ArchiveKind {
569569
K_COFF,
570570
}
571571

572-
/// LLVMRustPassKind
573-
#[derive(Copy, Clone, PartialEq, Debug)]
574-
#[repr(C)]
575-
#[allow(dead_code)] // Variants constructed by C++.
576-
pub enum PassKind {
577-
Other,
578-
Function,
579-
Module,
580-
}
581-
582572
// LLVMRustThinLTOData
583573
extern "C" {
584574
pub type ThinLTOData;
@@ -589,10 +579,6 @@ extern "C" {
589579
pub type ThinLTOBuffer;
590580
}
591581

592-
// LLVMRustModuleNameCallback
593-
pub type ThinLTOModuleNameCallback =
594-
unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
595-
596582
/// LLVMRustThinLTOModule
597583
#[repr(C)]
598584
pub struct ThinLTOModule {
@@ -658,9 +644,6 @@ extern "C" {
658644
}
659645
#[repr(C)]
660646
pub struct Builder<'a>(InvariantOpaque<'a>);
661-
extern "C" {
662-
pub type MemoryBuffer;
663-
}
664647
#[repr(C)]
665648
pub struct PassManager<'a>(InvariantOpaque<'a>);
666649
extern "C" {
@@ -1013,7 +996,6 @@ extern "C" {
1013996
pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
1014997

1015998
/// See Module::setModuleInlineAsm.
1016-
pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
1017999
pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
10181000

10191001
/// See llvm::LLVMTypeKind::getTypeID.
@@ -1167,7 +1149,6 @@ extern "C" {
11671149
pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
11681150
pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
11691151
pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
1170-
pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
11711152
pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
11721153
pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
11731154
pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
@@ -2246,7 +2227,6 @@ extern "C" {
22462227

22472228
pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
22482229

2249-
pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
22502230
pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
22512231
pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
22522232
pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
@@ -2363,7 +2343,6 @@ extern "C" {
23632343
) -> LLVMRustResult;
23642344
pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
23652345
pub fn LLVMRustPrintPasses();
2366-
pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
23672346
pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
23682347
pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
23692348
pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
@@ -2461,7 +2440,6 @@ extern "C" {
24612440
pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
24622441

24632442
pub fn LLVMRustSetComdat<'a>(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2464-
pub fn LLVMRustUnsetComdat(V: &Value);
24652443
pub fn LLVMRustSetModulePICLevel(M: &Module);
24662444
pub fn LLVMRustSetModulePIELevel(M: &Module);
24672445
pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
@@ -2493,11 +2471,6 @@ extern "C" {
24932471
Module: &Module,
24942472
Target: &TargetMachine,
24952473
) -> bool;
2496-
pub fn LLVMRustGetThinLTOModuleImports(
2497-
Data: *const ThinLTOData,
2498-
ModuleNameCallback: ThinLTOModuleNameCallback,
2499-
CallbackPayload: *mut c_void,
2500-
);
25012474
pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
25022475
pub fn LLVMRustParseBitcodeForLTO(
25032476
Context: &Context,

compiler/rustc_codegen_llvm/src/llvm/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,6 @@ pub fn SetUniqueComdat(llmod: &Module, val: &Value) {
158158
}
159159
}
160160

161-
pub fn UnsetComdat(val: &Value) {
162-
unsafe {
163-
LLVMRustUnsetComdat(val);
164-
}
165-
}
166-
167161
pub fn SetUnnamedAddress(global: &Value, unnamed: UnnamedAddr) {
168162
unsafe {
169163
LLVMSetUnnamedAddress(global, unnamed);

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

-45
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,6 @@ extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) {
9090
timeTraceProfilerCleanup();
9191
}
9292

93-
enum class LLVMRustPassKind {
94-
Other,
95-
Function,
96-
Module,
97-
};
98-
99-
static LLVMRustPassKind toRust(PassKind Kind) {
100-
switch (Kind) {
101-
case PT_Function:
102-
return LLVMRustPassKind::Function;
103-
case PT_Module:
104-
return LLVMRustPassKind::Module;
105-
default:
106-
return LLVMRustPassKind::Other;
107-
}
108-
}
109-
11093
extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
11194
#if LLVM_VERSION_LT(15, 0)
11295
StringRef SR(PassName);
@@ -172,12 +155,6 @@ extern "C" LLVMPassRef LLVMRustCreateHWAddressSanitizerPass(bool Recover) {
172155
#endif
173156
}
174157

175-
extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
176-
assert(RustPass);
177-
Pass *Pass = unwrap(RustPass);
178-
return toRust(Pass->getPassKind());
179-
}
180-
181158
extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
182159
#if LLVM_VERSION_LT(15, 0)
183160
assert(RustPass);
@@ -1604,28 +1581,6 @@ LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M,
16041581
return true;
16051582
}
16061583

1607-
extern "C" typedef void (*LLVMRustModuleNameCallback)(void*, // payload
1608-
const char*, // importing module name
1609-
const char*); // imported module name
1610-
1611-
// Calls `module_name_callback` for each module import done by ThinLTO.
1612-
// The callback is provided with regular null-terminated C strings.
1613-
extern "C" void
1614-
LLVMRustGetThinLTOModules(const LLVMRustThinLTOData *data,
1615-
LLVMRustModuleNameCallback module_name_callback,
1616-
void* callback_payload) {
1617-
for (const auto& importing_module : data->ImportLists) {
1618-
const std::string importing_module_id = importing_module.getKey().str();
1619-
const auto& imports = importing_module.getValue();
1620-
for (const auto& imported_module : imports) {
1621-
const std::string imported_module_id = imported_module.getKey().str();
1622-
module_name_callback(callback_payload,
1623-
importing_module_id.c_str(),
1624-
imported_module_id.c_str());
1625-
}
1626-
}
1627-
}
1628-
16291584
// This struct and various functions are sort of a hack right now, but the
16301585
// problem is that we've got in-memory LLVM modules after we generate and
16311586
// optimize all codegen-units for one compilation in rustc. To be compatible

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ extern "C" char *LLVMRustGetLastError(void) {
8888
return Ret;
8989
}
9090

91-
extern "C" unsigned int LLVMRustGetInstructionCount(LLVMModuleRef M) {
92-
return unwrap(M)->getInstructionCount();
93-
}
94-
9591
extern "C" void LLVMRustSetLastError(const char *Err) {
9692
free((void *)LastError);
9793
LastError = strdup(Err);
@@ -1460,11 +1456,6 @@ extern "C" void LLVMRustSetComdat(LLVMModuleRef M, LLVMValueRef V,
14601456
}
14611457
}
14621458

1463-
extern "C" void LLVMRustUnsetComdat(LLVMValueRef V) {
1464-
GlobalObject *GV = unwrap<GlobalObject>(V);
1465-
GV->setComdat(nullptr);
1466-
}
1467-
14681459
enum class LLVMRustLinkage {
14691460
ExternalLinkage = 0,
14701461
AvailableExternallyLinkage = 1,

0 commit comments

Comments
 (0)