From 92189bc521ce3256a53c1b435dfb6ec6740f4734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Fri, 5 Jan 2018 14:27:20 +0100 Subject: [PATCH 1/4] Remove redundant -Zdebug-llvm option The same effect can be achieved using -Cllvm-args=-debug Refs #46437 as it removes LLVMRustSetDebug() --- src/librustc/session/config.rs | 4 ---- src/librustc_driver/lib.rs | 5 ----- src/librustc_llvm/ffi.rs | 3 --- src/librustc_trans/lib.rs | 2 +- src/librustc_trans/llvm_util.rs | 4 ---- src/rustllvm/RustWrapper.cpp | 6 ------ 6 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 05b1d584e9c..5e470e8d86e 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1084,8 +1084,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "omit landing pads for unwinding"), fewer_names: bool = (false, parse_bool, [TRACKED], "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR)"), - debug_llvm: bool = (false, parse_bool, [UNTRACKED], - "enable debug output from LLVM"), meta_stats: bool = (false, parse_bool, [UNTRACKED], "gather metadata statistics"), print_link_args: bool = (false, parse_bool, [UNTRACKED], @@ -2747,8 +2745,6 @@ mod tests { assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.borrowck_stats = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); - opts.debugging_opts.debug_llvm = true; - assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.meta_stats = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.print_link_args = true; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 223c602ccd3..237656eb43c 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -167,7 +167,6 @@ mod rustc_trans { pub use rustc_trans_utils::trans_crate::TranslatedCrate as CrateTranslation; pub fn init(_sess: &Session) {} - pub fn enable_llvm_debug() {} pub fn print_version() {} pub fn print_passes() {} pub fn print(_req: PrintRequest, _sess: &Session) {} @@ -205,10 +204,6 @@ pub fn run_compiler<'a>(args: &[String], let (sopts, cfg) = config::build_session_options_and_crate_config(&matches); - if sopts.debugging_opts.debug_llvm { - rustc_trans::enable_llvm_debug(); - } - let descriptions = diagnostics_registry(); do_or_return!(callbacks.early_callback(&matches, diff --git a/src/librustc_llvm/ffi.rs b/src/librustc_llvm/ffi.rs index 6cb1a2b5334..79909c3c5ae 100644 --- a/src/librustc_llvm/ffi.rs +++ b/src/librustc_llvm/ffi.rs @@ -1315,9 +1315,6 @@ extern "C" { ElementCount: c_uint, Packed: Bool); - /// Enables LLVM debug output. - pub fn LLVMRustSetDebug(Enabled: c_int); - /// Prepares inline assembly. pub fn LLVMRustInlineAsm(Ty: TypeRef, AsmString: *const c_char, diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 039dd94465d..fd6cd5c371d 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -69,7 +69,7 @@ pub use base::trans_crate; use back::bytecode::RLIB_BYTECODE_EXTENSION; pub use metadata::LlvmMetadataLoader; -pub use llvm_util::{init, target_features, print_version, print_passes, print, enable_llvm_debug}; +pub use llvm_util::{init, target_features, print_version, print_passes, print}; use std::any::Any; use std::path::PathBuf; diff --git a/src/librustc_trans/llvm_util.rs b/src/librustc_trans/llvm_util.rs index a9ea96134fa..b3d0b574d1d 100644 --- a/src/librustc_trans/llvm_util.rs +++ b/src/librustc_trans/llvm_util.rs @@ -140,7 +140,3 @@ pub fn print(req: PrintRequest, sess: &Session) { } } } - -pub fn enable_llvm_debug() { - unsafe { llvm::LLVMRustSetDebug(1); } -} diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 0fac7f7bf28..e9eaad853d5 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -384,12 +384,6 @@ LLVMRustBuildAtomicFence(LLVMBuilderRef B, LLVMAtomicOrdering Order, return wrap(unwrap(B)->CreateFence(fromRust(Order), fromRust(Scope))); } -extern "C" void LLVMRustSetDebug(int Enabled) { -#ifndef NDEBUG - DebugFlag = Enabled; -#endif -} - enum class LLVMRustAsmDialect { Other, Att, From 4be1d5c37be04b8a84aa34081238746a0967016f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Fri, 5 Jan 2018 14:28:50 +0100 Subject: [PATCH 2/4] Remove dead function LLVMRustLinkInParsedExternalBitcode() Refs #46437 --- src/librustc_llvm/ffi.rs | 1 - src/rustllvm/RustWrapper.cpp | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/src/librustc_llvm/ffi.rs b/src/librustc_llvm/ffi.rs index 79909c3c5ae..8ed3953b814 100644 --- a/src/librustc_llvm/ffi.rs +++ b/src/librustc_llvm/ffi.rs @@ -1607,7 +1607,6 @@ extern "C" { pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char); pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef, AddLifetimes: bool); pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef, bc: *const c_char, len: size_t) -> bool; - pub fn LLVMRustLinkInParsedExternalBitcode(M: ModuleRef, M: ModuleRef) -> bool; pub fn LLVMRustRunRestrictionPass(M: ModuleRef, syms: *const *const c_char, len: size_t); pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef); diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index e9eaad853d5..8030a545ec3 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -927,23 +927,6 @@ extern "C" bool LLVMRustLinkInExternalBitcode(LLVMModuleRef DstRef, char *BC, return true; } -extern "C" bool LLVMRustLinkInParsedExternalBitcode( - LLVMModuleRef DstRef, LLVMModuleRef SrcRef) { -#if LLVM_VERSION_GE(4, 0) - Module *Dst = unwrap(DstRef); - std::unique_ptr Src(unwrap(SrcRef)); - - if (Linker::linkModules(*Dst, std::move(Src))) { - LLVMRustSetLastError("failed to link modules"); - return false; - } - return true; -#else - LLVMRustSetLastError("can't link parsed modules on this LLVM"); - return false; -#endif -} - // Note that the two following functions look quite similar to the // LLVMGetSectionName function. Sadly, it appears that this function only // returns a char* pointer, which isn't guaranteed to be null-terminated. The From ebc85077df1ebc603e24495151ba5db1159a42d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Fri, 5 Jan 2018 15:22:35 +0100 Subject: [PATCH 3/4] Remove dead function rustc_llvm::debug_loc_to_string() Refs #46437 as it also removes LLVMRustWriteDebugLocToString() --- src/librustc_llvm/ffi.rs | 2 -- src/librustc_llvm/lib.rs | 5 ----- src/rustllvm/RustWrapper.cpp | 8 -------- src/rustllvm/rustllvm.h | 1 - 4 files changed, 16 deletions(-) diff --git a/src/librustc_llvm/ffi.rs b/src/librustc_llvm/ffi.rs index 8ed3953b814..2cfb151ae85 100644 --- a/src/librustc_llvm/ffi.rs +++ b/src/librustc_llvm/ffi.rs @@ -1642,8 +1642,6 @@ extern "C" { pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef); pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind; - pub fn LLVMRustWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef); - pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef, H: InlineAsmDiagHandler, CX: *mut c_void); diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 592bd620564..c75a026a0f8 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -296,11 +296,6 @@ pub unsafe fn twine_to_string(tr: TwineRef) -> String { build_string(|s| LLVMRustWriteTwineToString(tr, s)).expect("got a non-UTF8 Twine from LLVM") } -pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String { - build_string(|s| LLVMRustWriteDebugLocToString(c, tr, s)) - .expect("got a non-UTF8 DebugLoc from LLVM") -} - pub fn initialize_available_targets() { macro_rules! init_target( ($cfg:meta, $($method:ident),*) => { { diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 8030a545ec3..95130d596e1 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -958,7 +958,6 @@ extern "C" LLVMTypeRef LLVMRustArrayType(LLVMTypeRef ElementTy, } DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Twine, LLVMTwineRef) -DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DebugLoc, LLVMDebugLocRef) extern "C" void LLVMRustWriteTwineToString(LLVMTwineRef T, RustStringRef Str) { RawRustStringOstream OS(Str); @@ -1107,13 +1106,6 @@ extern "C" LLVMTypeKind LLVMRustGetTypeKind(LLVMTypeRef Ty) { report_fatal_error("Unhandled TypeID."); } -extern "C" void LLVMRustWriteDebugLocToString(LLVMContextRef C, - LLVMDebugLocRef DL, - RustStringRef Str) { - RawRustStringOstream OS(Str); - unwrap(DL)->print(OS); -} - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(SMDiagnostic, LLVMSMDiagnosticRef) extern "C" void LLVMRustSetInlineAsmDiagnosticHandler( diff --git a/src/rustllvm/rustllvm.h b/src/rustllvm/rustllvm.h index 714173f8602..b92834bc940 100644 --- a/src/rustllvm/rustllvm.h +++ b/src/rustllvm/rustllvm.h @@ -103,7 +103,6 @@ enum LLVMRustAttribute { typedef struct OpaqueRustString *RustStringRef; typedef struct LLVMOpaqueTwine *LLVMTwineRef; -typedef struct LLVMOpaqueDebugLoc *LLVMDebugLocRef; typedef struct LLVMOpaqueSMDiagnostic *LLVMSMDiagnosticRef; typedef struct LLVMOpaqueRustJITMemoryManager *LLVMRustJITMemoryManagerRef; From 907855fe885a3ea5b35179b54a0f19e0616b4e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Sat, 6 Jan 2018 12:38:52 +0100 Subject: [PATCH 4/4] Remove unused LLVMRustJITMemoryManagerRef typedef --- src/rustllvm/rustllvm.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rustllvm/rustllvm.h b/src/rustllvm/rustllvm.h index b92834bc940..f4bd78147f6 100644 --- a/src/rustllvm/rustllvm.h +++ b/src/rustllvm/rustllvm.h @@ -104,7 +104,6 @@ enum LLVMRustAttribute { typedef struct OpaqueRustString *RustStringRef; typedef struct LLVMOpaqueTwine *LLVMTwineRef; typedef struct LLVMOpaqueSMDiagnostic *LLVMSMDiagnosticRef; -typedef struct LLVMOpaqueRustJITMemoryManager *LLVMRustJITMemoryManagerRef; extern "C" void LLVMRustStringWriteImpl(RustStringRef Str, const char *Ptr, size_t Size);