mirror of
https://github.com/rust-lang/rust
synced 2024-10-03 07:14:34 +00:00
Remove dead code from cg_llvm
This commit is contained in:
parent
b629c85bd7
commit
017e1726ff
|
@ -20,19 +20,6 @@ pub enum OptimizationDiagnosticKind {
|
||||||
OptimizationRemarkOther,
|
OptimizationRemarkOther,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OptimizationDiagnosticKind {
|
|
||||||
pub fn describe(self) -> &'static str {
|
|
||||||
match self {
|
|
||||||
OptimizationRemark | OptimizationRemarkOther => "remark",
|
|
||||||
OptimizationMissed => "missed",
|
|
||||||
OptimizationAnalysis => "analysis",
|
|
||||||
OptimizationAnalysisFPCommute => "floating-point",
|
|
||||||
OptimizationAnalysisAliasing => "aliasing",
|
|
||||||
OptimizationFailure => "failure",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct OptimizationDiagnostic<'ll> {
|
pub struct OptimizationDiagnostic<'ll> {
|
||||||
pub kind: OptimizationDiagnosticKind,
|
pub kind: OptimizationDiagnosticKind,
|
||||||
pub pass_name: String,
|
pub pass_name: String,
|
||||||
|
|
|
@ -569,16 +569,6 @@ pub enum ArchiveKind {
|
||||||
K_COFF,
|
K_COFF,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// LLVMRustPassKind
|
|
||||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
|
||||||
#[repr(C)]
|
|
||||||
#[allow(dead_code)] // Variants constructed by C++.
|
|
||||||
pub enum PassKind {
|
|
||||||
Other,
|
|
||||||
Function,
|
|
||||||
Module,
|
|
||||||
}
|
|
||||||
|
|
||||||
// LLVMRustThinLTOData
|
// LLVMRustThinLTOData
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub type ThinLTOData;
|
pub type ThinLTOData;
|
||||||
|
@ -589,10 +579,6 @@ pub enum PassKind {
|
||||||
pub type ThinLTOBuffer;
|
pub type ThinLTOBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LLVMRustModuleNameCallback
|
|
||||||
pub type ThinLTOModuleNameCallback =
|
|
||||||
unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
|
|
||||||
|
|
||||||
/// LLVMRustThinLTOModule
|
/// LLVMRustThinLTOModule
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ThinLTOModule {
|
pub struct ThinLTOModule {
|
||||||
|
@ -658,9 +644,6 @@ struct InvariantOpaque<'a> {
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct Builder<'a>(InvariantOpaque<'a>);
|
pub struct Builder<'a>(InvariantOpaque<'a>);
|
||||||
extern "C" {
|
|
||||||
pub type MemoryBuffer;
|
|
||||||
}
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct PassManager<'a>(InvariantOpaque<'a>);
|
pub struct PassManager<'a>(InvariantOpaque<'a>);
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -1013,7 +996,6 @@ pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
|
||||||
pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
|
pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
|
||||||
|
|
||||||
/// See Module::setModuleInlineAsm.
|
/// See Module::setModuleInlineAsm.
|
||||||
pub fn LLVMSetModuleInlineAsm2(M: &Module, Asm: *const c_char, AsmLen: size_t);
|
|
||||||
pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
|
pub fn LLVMRustAppendModuleInlineAsm(M: &Module, Asm: *const c_char, AsmLen: size_t);
|
||||||
|
|
||||||
/// See llvm::LLVMTypeKind::getTypeID.
|
/// See llvm::LLVMTypeKind::getTypeID.
|
||||||
|
@ -1167,7 +1149,6 @@ pub fn LLVMRustGetOrInsertGlobal<'a>(
|
||||||
pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
|
pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
|
||||||
pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
|
pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
|
||||||
pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
|
pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
|
||||||
pub fn LLVMSetThreadLocal(GlobalVar: &Value, IsThreadLocal: Bool);
|
|
||||||
pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
|
pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
|
||||||
pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
|
pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
|
||||||
pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
|
pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
|
||||||
|
@ -2246,7 +2227,6 @@ pub fn LLVMRustDIBuilderCreateDebugLocation<'a>(
|
||||||
|
|
||||||
pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
|
pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
|
||||||
|
|
||||||
pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
|
|
||||||
pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
|
pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
|
||||||
pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
|
pub fn LLVMRustCreateAddressSanitizerFunctionPass(Recover: bool) -> &'static mut Pass;
|
||||||
pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
|
pub fn LLVMRustCreateModuleAddressSanitizerPass(Recover: bool) -> &'static mut Pass;
|
||||||
|
@ -2363,7 +2343,6 @@ pub fn LLVMRustPrintModule(
|
||||||
) -> LLVMRustResult;
|
) -> LLVMRustResult;
|
||||||
pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
|
pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
|
||||||
pub fn LLVMRustPrintPasses();
|
pub fn LLVMRustPrintPasses();
|
||||||
pub fn LLVMRustGetInstructionCount(M: &Module) -> u32;
|
|
||||||
pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
|
pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
|
||||||
pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
|
pub fn LLVMRustAddAlwaysInlinePass(P: &PassManagerBuilder, AddLifetimes: bool);
|
||||||
pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
|
pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
|
||||||
|
@ -2461,7 +2440,6 @@ pub fn LLVMRustBuildOperandBundleDef<'a>(
|
||||||
pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
|
pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
|
||||||
|
|
||||||
pub fn LLVMRustSetComdat<'a>(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
|
pub fn LLVMRustSetComdat<'a>(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
|
||||||
pub fn LLVMRustUnsetComdat(V: &Value);
|
|
||||||
pub fn LLVMRustSetModulePICLevel(M: &Module);
|
pub fn LLVMRustSetModulePICLevel(M: &Module);
|
||||||
pub fn LLVMRustSetModulePIELevel(M: &Module);
|
pub fn LLVMRustSetModulePIELevel(M: &Module);
|
||||||
pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
|
pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
|
||||||
|
@ -2493,11 +2471,6 @@ pub fn LLVMRustPrepareThinLTOImport(
|
||||||
Module: &Module,
|
Module: &Module,
|
||||||
Target: &TargetMachine,
|
Target: &TargetMachine,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
pub fn LLVMRustGetThinLTOModuleImports(
|
|
||||||
Data: *const ThinLTOData,
|
|
||||||
ModuleNameCallback: ThinLTOModuleNameCallback,
|
|
||||||
CallbackPayload: *mut c_void,
|
|
||||||
);
|
|
||||||
pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
|
pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
|
||||||
pub fn LLVMRustParseBitcodeForLTO(
|
pub fn LLVMRustParseBitcodeForLTO(
|
||||||
Context: &Context,
|
Context: &Context,
|
||||||
|
|
|
@ -158,12 +158,6 @@ pub fn SetUniqueComdat(llmod: &Module, val: &Value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn UnsetComdat(val: &Value) {
|
|
||||||
unsafe {
|
|
||||||
LLVMRustUnsetComdat(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn SetUnnamedAddress(global: &Value, unnamed: UnnamedAddr) {
|
pub fn SetUnnamedAddress(global: &Value, unnamed: UnnamedAddr) {
|
||||||
unsafe {
|
unsafe {
|
||||||
LLVMSetUnnamedAddress(global, unnamed);
|
LLVMSetUnnamedAddress(global, unnamed);
|
||||||
|
|
|
@ -90,23 +90,6 @@ extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) {
|
||||||
timeTraceProfilerCleanup();
|
timeTraceProfilerCleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class LLVMRustPassKind {
|
|
||||||
Other,
|
|
||||||
Function,
|
|
||||||
Module,
|
|
||||||
};
|
|
||||||
|
|
||||||
static LLVMRustPassKind toRust(PassKind Kind) {
|
|
||||||
switch (Kind) {
|
|
||||||
case PT_Function:
|
|
||||||
return LLVMRustPassKind::Function;
|
|
||||||
case PT_Module:
|
|
||||||
return LLVMRustPassKind::Module;
|
|
||||||
default:
|
|
||||||
return LLVMRustPassKind::Other;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
|
extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
|
||||||
#if LLVM_VERSION_LT(15, 0)
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
StringRef SR(PassName);
|
StringRef SR(PassName);
|
||||||
|
@ -172,12 +155,6 @@ extern "C" LLVMPassRef LLVMRustCreateHWAddressSanitizerPass(bool Recover) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
|
|
||||||
assert(RustPass);
|
|
||||||
Pass *Pass = unwrap(RustPass);
|
|
||||||
return toRust(Pass->getPassKind());
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
|
extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
|
||||||
#if LLVM_VERSION_LT(15, 0)
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
assert(RustPass);
|
assert(RustPass);
|
||||||
|
@ -1604,28 +1581,6 @@ LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" typedef void (*LLVMRustModuleNameCallback)(void*, // payload
|
|
||||||
const char*, // importing module name
|
|
||||||
const char*); // imported module name
|
|
||||||
|
|
||||||
// Calls `module_name_callback` for each module import done by ThinLTO.
|
|
||||||
// The callback is provided with regular null-terminated C strings.
|
|
||||||
extern "C" void
|
|
||||||
LLVMRustGetThinLTOModules(const LLVMRustThinLTOData *data,
|
|
||||||
LLVMRustModuleNameCallback module_name_callback,
|
|
||||||
void* callback_payload) {
|
|
||||||
for (const auto& importing_module : data->ImportLists) {
|
|
||||||
const std::string importing_module_id = importing_module.getKey().str();
|
|
||||||
const auto& imports = importing_module.getValue();
|
|
||||||
for (const auto& imported_module : imports) {
|
|
||||||
const std::string imported_module_id = imported_module.getKey().str();
|
|
||||||
module_name_callback(callback_payload,
|
|
||||||
importing_module_id.c_str(),
|
|
||||||
imported_module_id.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This struct and various functions are sort of a hack right now, but the
|
// This struct and various functions are sort of a hack right now, but the
|
||||||
// problem is that we've got in-memory LLVM modules after we generate and
|
// problem is that we've got in-memory LLVM modules after we generate and
|
||||||
// optimize all codegen-units for one compilation in rustc. To be compatible
|
// optimize all codegen-units for one compilation in rustc. To be compatible
|
||||||
|
|
|
@ -88,10 +88,6 @@ extern "C" char *LLVMRustGetLastError(void) {
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" unsigned int LLVMRustGetInstructionCount(LLVMModuleRef M) {
|
|
||||||
return unwrap(M)->getInstructionCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void LLVMRustSetLastError(const char *Err) {
|
extern "C" void LLVMRustSetLastError(const char *Err) {
|
||||||
free((void *)LastError);
|
free((void *)LastError);
|
||||||
LastError = strdup(Err);
|
LastError = strdup(Err);
|
||||||
|
@ -1460,11 +1456,6 @@ extern "C" void LLVMRustSetComdat(LLVMModuleRef M, LLVMValueRef V,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LLVMRustUnsetComdat(LLVMValueRef V) {
|
|
||||||
GlobalObject *GV = unwrap<GlobalObject>(V);
|
|
||||||
GV->setComdat(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class LLVMRustLinkage {
|
enum class LLVMRustLinkage {
|
||||||
ExternalLinkage = 0,
|
ExternalLinkage = 0,
|
||||||
AvailableExternallyLinkage = 1,
|
AvailableExternallyLinkage = 1,
|
||||||
|
|
Loading…
Reference in a new issue