Skip to content

Commit 3840645

Browse files
authored
Rollup merge of rust-lang#52505 - alexcrichton:remove-thinlto-hack, r=nikomatsakis
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
2 parents 3bea4d1 + 829bc26 commit 3840645

File tree

3 files changed

+0
-29
lines changed

3 files changed

+0
-29
lines changed

src/librustc_codegen_llvm/back/lto.rs

-14
Original file line numberDiff line numberDiff line change
@@ -759,20 +759,6 @@ impl ThinModule {
759759
cgcx.save_temp_bitcode(&module, "thin-lto-after-pm");
760760
timeline.record("thin-done");
761761

762-
// FIXME: this is a hack around a bug in LLVM right now. Discovered in
763-
// #46910 it was found out that on 32-bit MSVC LLVM will hit a codegen
764-
// error if there's an available_externally function in the LLVM module.
765-
// Typically we don't actually use these functions but ThinLTO makes
766-
// heavy use of them when inlining across modules.
767-
//
768-
// Tracked upstream at https://bugs.llvm.org/show_bug.cgi?id=35736 this
769-
// function call (and its definition on the C++ side of things)
770-
// shouldn't be necessary eventually and we can safetly delete these few
771-
// lines.
772-
llvm::LLVMRustThinLTORemoveAvailableExternally(llmod);
773-
cgcx.save_temp_bitcode(&module, "thin-lto-after-rm-ae");
774-
timeline.record("no-ae");
775-
776762
Ok(module)
777763
}
778764
}

src/librustc_llvm/ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,6 @@ extern "C" {
17911791
CU1: *mut *mut c_void,
17921792
CU2: *mut *mut c_void);
17931793
pub fn LLVMRustThinLTOPatchDICompileUnit(M: ModuleRef, CU: *mut c_void);
1794-
pub fn LLVMRustThinLTORemoveAvailableExternally(M: ModuleRef);
17951794

17961795
pub fn LLVMRustLinkerNew(M: ModuleRef) -> LinkerRef;
17971796
pub fn LLVMRustLinkerAdd(linker: LinkerRef,

src/rustllvm/PassWrapper.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -1228,15 +1228,6 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod, DICompileUnit *Unit) {
12281228
MD->addOperand(Unit);
12291229
}
12301230

1231-
extern "C" void
1232-
LLVMRustThinLTORemoveAvailableExternally(LLVMModuleRef Mod) {
1233-
Module *M = unwrap(Mod);
1234-
for (Function &F : M->functions()) {
1235-
if (F.hasAvailableExternallyLinkage())
1236-
F.deleteBody();
1237-
}
1238-
}
1239-
12401231
#else
12411232

12421233
extern "C" bool
@@ -1328,9 +1319,4 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod) {
13281319
report_fatal_error("ThinLTO not available");
13291320
}
13301321

1331-
extern "C" void
1332-
LLVMRustThinLTORemoveAvailableExternally(LLVMModuleRef Mod) {
1333-
report_fatal_error("ThinLTO not available");
1334-
}
1335-
13361322
#endif // LLVM_VERSION_GE(4, 0)

0 commit comments

Comments
 (0)