]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #52505 - alexcrichton:remove-thinlto-hack, r=nikomatsakis
authorkennytm <kennytm@gmail.com>
Fri, 20 Jul 2018 18:59:05 +0000 (02:59 +0800)
committerkennytm <kennytm@gmail.com>
Fri, 20 Jul 2018 20:08:06 +0000 (04:08 +0800)
rustc: Remove a workaround in ThinLTO fixed upstream

This commit removes a hack in our ThinLTO passes which removes available
externally functions manually. The [upstream bug][1] has long since been fixed,
so we should be able to rely on LLVM natively for this now!

[1]: https://bugs.llvm.org/show_bug.cgi?id=35736

src/librustc_codegen_llvm/back/lto.rs
src/librustc_llvm/ffi.rs
src/rustllvm/PassWrapper.cpp

index a33f8b569d0a8585e3cee4a92ffbf70e90b19699..60b5cf2ec765134f4d95ca629e34a574acf825d1 100644 (file)
@@ -759,20 +759,6 @@ unsafe fn optimize(&mut self, cgcx: &CodegenContext, timeline: &mut Timeline)
         cgcx.save_temp_bitcode(&module, "thin-lto-after-pm");
         timeline.record("thin-done");
 
-        // FIXME: this is a hack around a bug in LLVM right now. Discovered in
-        // #46910 it was found out that on 32-bit MSVC LLVM will hit a codegen
-        // error if there's an available_externally function in the LLVM module.
-        // Typically we don't actually use these functions but ThinLTO makes
-        // heavy use of them when inlining across modules.
-        //
-        // Tracked upstream at https://bugs.llvm.org/show_bug.cgi?id=35736 this
-        // function call (and its definition on the C++ side of things)
-        // shouldn't be necessary eventually and we can safetly delete these few
-        // lines.
-        llvm::LLVMRustThinLTORemoveAvailableExternally(llmod);
-        cgcx.save_temp_bitcode(&module, "thin-lto-after-rm-ae");
-        timeline.record("no-ae");
-
         Ok(module)
     }
 }
index b4483557dd33fe53816ae93598df910fa67b169f..8d04438eea29000edf06fbeb0b26af50010d19e2 100644 (file)
@@ -1791,7 +1791,6 @@ pub fn LLVMRustThinLTOGetDICompileUnit(M: ModuleRef,
                                            CU1: *mut *mut c_void,
                                            CU2: *mut *mut c_void);
     pub fn LLVMRustThinLTOPatchDICompileUnit(M: ModuleRef, CU: *mut c_void);
-    pub fn LLVMRustThinLTORemoveAvailableExternally(M: ModuleRef);
 
     pub fn LLVMRustLinkerNew(M: ModuleRef) -> LinkerRef;
     pub fn LLVMRustLinkerAdd(linker: LinkerRef,
index a00ff3b345d116e4c0127fde7c4d3f07f15ea6ab..2f28c5b32fb88de32c0e490a1df7301dc55a5dcc 100644 (file)
@@ -1228,15 +1228,6 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod, DICompileUnit *Unit) {
   MD->addOperand(Unit);
 }
 
-extern "C" void
-LLVMRustThinLTORemoveAvailableExternally(LLVMModuleRef Mod) {
-  Module *M = unwrap(Mod);
-  for (Function &F : M->functions()) {
-    if (F.hasAvailableExternallyLinkage())
-      F.deleteBody();
-  }
-}
-
 #else
 
 extern "C" bool
@@ -1328,9 +1319,4 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod) {
   report_fatal_error("ThinLTO not available");
 }
 
-extern "C" void
-LLVMRustThinLTORemoveAvailableExternally(LLVMModuleRef Mod) {
-  report_fatal_error("ThinLTO not available");
-}
-
 #endif // LLVM_VERSION_GE(4, 0)