@@ -25,7 +25,6 @@ use std::fs::File;
2525use std:: io;
2626use std:: iter;
2727use std:: path:: Path ;
28- use std:: ptr;
2928use std:: slice;
3029use std:: sync:: Arc ;
3130
@@ -709,17 +708,6 @@ pub unsafe fn optimize_thin_module(
709708 let llmod = module. module_llvm . llmod ( ) ;
710709 save_temp_bitcode ( cgcx, & module, "thin-lto-input" ) ;
711710
712- // Before we do much else find the "main" `DICompileUnit` that we'll be
713- // using below. If we find more than one though then rustc has changed
714- // in a way we're not ready for, so generate an ICE by returning
715- // an error.
716- let mut cu1 = ptr:: null_mut ( ) ;
717- let mut cu2 = ptr:: null_mut ( ) ;
718- llvm:: LLVMRustThinLTOGetDICompileUnit ( llmod, & mut cu1, & mut cu2) ;
719- if !cu2. is_null ( ) {
720- return Err ( write:: llvm_err ( & diag_handler, LlvmError :: MultipleSourceDiCompileUnit ) ) ;
721- }
722-
723711 // Up next comes the per-module local analyses that we do for Thin LTO.
724712 // Each of these functions is basically copied from the LLVM
725713 // implementation and then tailored to suit this implementation. Ideally
@@ -766,43 +754,6 @@ pub unsafe fn optimize_thin_module(
766754 save_temp_bitcode ( cgcx, & module, "thin-lto-after-import" ) ;
767755 }
768756
769- // Ok now this is a bit unfortunate. This is also something you won't
770- // find upstream in LLVM's ThinLTO passes! This is a hack for now to
771- // work around bugs in LLVM.
772- //
773- // First discovered in #45511 it was found that as part of ThinLTO
774- // importing passes LLVM will import `DICompileUnit` metadata
775- // information across modules. This means that we'll be working with one
776- // LLVM module that has multiple `DICompileUnit` instances in it (a
777- // bunch of `llvm.dbg.cu` members). Unfortunately there's a number of
778- // bugs in LLVM's backend which generates invalid DWARF in a situation
779- // like this:
780- //
781- // https://bugs.llvm.org/show_bug.cgi?id=35212
782- // https://bugs.llvm.org/show_bug.cgi?id=35562
783- //
784- // While the first bug there is fixed the second ended up causing #46346
785- // which was basically a resurgence of #45511 after LLVM's bug 35212 was
786- // fixed.
787- //
788- // This function below is a huge hack around this problem. The function
789- // below is defined in `PassWrapper.cpp` and will basically "merge"
790- // all `DICompileUnit` instances in a module. Basically it'll take all
791- // the objects, rewrite all pointers of `DISubprogram` to point to the
792- // first `DICompileUnit`, and then delete all the other units.
793- //
794- // This is probably mangling to the debug info slightly (but hopefully
795- // not too much) but for now at least gets LLVM to emit valid DWARF (or
796- // so it appears). Hopefully we can remove this once upstream bugs are
797- // fixed in LLVM.
798- {
799- let _timer = cgcx
800- . prof
801- . generic_activity_with_arg ( "LLVM_thin_lto_patch_debuginfo" , thin_module. name ( ) ) ;
802- llvm:: LLVMRustThinLTOPatchDICompileUnit ( llmod, cu1) ;
803- save_temp_bitcode ( cgcx, & module, "thin-lto-after-patch" ) ;
804- }
805-
806757 // Alright now that we've done everything related to the ThinLTO
807758 // analysis it's time to run some optimizations! Here we use the same
808759 // `run_pass_manager` as the "fat" LTO above except that we tell it to
0 commit comments