Skip to content

Commit 7f608e9

Browse files
authored
Rollup merge of #99759 - bjorn3:remove_llvm_dead_code, r=nikic
Remove dead code from cg_llvm Found while working on #97485
2 parents fe51d07 + 017e172 commit 7f608e9

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
@@ -572,16 +572,6 @@ pub enum ArchiveKind {
572572
K_COFF,
573573
}
574574

575-
/// LLVMRustPassKind
576-
#[derive(Copy, Clone, PartialEq, Debug)]
577-
#[repr(C)]
578-
#[allow(dead_code)] // Variants constructed by C++.
579-
pub enum PassKind {
580-
Other,
581-
Function,
582-
Module,
583-
}
584-
585575
// LLVMRustThinLTOData
586576
extern "C" {
587577
pub type ThinLTOData;
@@ -592,10 +582,6 @@ extern "C" {
592582
pub type ThinLTOBuffer;
593583
}
594584

595-
// LLVMRustModuleNameCallback
596-
pub type ThinLTOModuleNameCallback =
597-
unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
598-
599585
/// LLVMRustThinLTOModule
600586
#[repr(C)]
601587
pub struct ThinLTOModule {
@@ -661,9 +647,6 @@ extern "C" {
661647
}
662648
#[repr(C)]
663649
pub struct Builder<'a>(InvariantOpaque<'a>);
664-
extern "C" {
665-
pub type MemoryBuffer;
666-
}
667650
#[repr(C)]
668651
pub struct PassManager<'a>(InvariantOpaque<'a>);
669652
extern "C" {
@@ -1032,7 +1015,6 @@ extern "C" {
10321015
pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
10331016

10341017
/// See Module::setModuleInlineAsm.
1035-
pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
10361018
pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
10371019

10381020
/// See llvm::LLVMTypeKind::getTypeID.
@@ -1186,7 +1168,6 @@ extern "C" {
11861168
pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
11871169
pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
11881170
pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
1189-
pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
11901171
pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
11911172
pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
11921173
pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
@@ -2267,7 +2248,6 @@ extern "C" {
22672248

22682249
pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
22692250

2270-
pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
22712251
pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
22722252
pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
22732253
pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
@@ -2384,7 +2364,6 @@ extern "C" {
23842364
) -> LLVMRustResult;
23852365
pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
23862366
pub fn LLVMRustPrintPasses();
2387-
pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
23882367
pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
23892368
pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
23902369
pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
@@ -2482,7 +2461,6 @@ extern "C" {
24822461
pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
24832462

24842463
pub fn LLVMRustSetComdat<'a>(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
2485-
pub fn LLVMRustUnsetComdat(V: &Value);
24862464
pub fn LLVMRustSetModulePICLevel(M: &Module);
24872465
pub fn LLVMRustSetModulePIELevel(M: &Module);
24882466
pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
@@ -2514,11 +2492,6 @@ extern "C" {
25142492
Module: &Module,
25152493
Target: &TargetMachine,
25162494
) -> bool;
2517-
pub fn LLVMRustGetThinLTOModuleImports(
2518-
Data: *const ThinLTOData,
2519-
ModuleNameCallback: ThinLTOModuleNameCallback,
2520-
CallbackPayload: *mut c_void,
2521-
);
25222495
pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
25232496
pub fn LLVMRustParseBitcodeForLTO(
25242497
Context: &Context,

compiler/rustc_codegen_llvm/src/llvm/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,6 @@ pub fn SetUniqueComdat(llmod: &Module, val: &Value) {
166166
}
167167
}
168168

169-
pub fn UnsetComdat(val: &Value) {
170-
unsafe {
171-
LLVMRustUnsetComdat(val);
172-
}
173-
}
174-
175169
pub fn SetUnnamedAddress(global: &Value, unnamed: UnnamedAddr) {
176170
unsafe {
177171
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);
@@ -1529,11 +1525,6 @@ extern "C" void LLVMRustSetComdat(LLVMModuleRef M, LLVMValueRef V,
15291525
}
15301526
}
15311527

1532-
extern "C" void LLVMRustUnsetComdat(LLVMValueRef V) {
1533-
GlobalObject *GV = unwrap<GlobalObject>(V);
1534-
GV->setComdat(nullptr);
1535-
}
1536-
15371528
enum class LLVMRustLinkage {
15381529
ExternalLinkage = 0,
15391530
AvailableExternallyLinkage = 1,

0 commit comments

Comments
 (0)