Skip to content

Commit ce5e155

Browse files
committed
Avoid recalculating UserBuiltinsSymbols
1 parent 08d1fad commit ce5e155

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

compiler/rustc_llvm/llvm-wrapper/Linker.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class ModuleLinker {
4949
StringSet<> UserBuiltinsSymbols;
5050
std::unique_ptr<Module> SrcM;
5151
bool SrcIsCompilerBuiltins;
52+
bool HasLinkedCompilerBuiltins = false;
5253

5354
SetVector<GlobalValue *> ValuesToLink;
5455

@@ -512,7 +513,12 @@ bool ModuleLinker::run() {
512513
ReplacedDstComdats.insert(DstC);
513514
}
514515

515-
if (SrcIsCompilerBuiltins) {
516+
if (!SrcIsCompilerBuiltins && HasLinkedCompilerBuiltins)
517+
llvm::report_fatal_error(
518+
"Expect only compiler-builtins to be linked at the end.");
519+
// We promise that compiler-builtins is linked at the end, so we only need to
520+
// compute it once.
521+
if (SrcIsCompilerBuiltins && !HasLinkedCompilerBuiltins) {
516522
ModuleSymbolTable SymbolTable;
517523
SymbolTable.addModule(&DstM);
518524
for (auto &Sym : SymbolTable.symbols()) {
@@ -635,6 +641,8 @@ bool ModuleLinker::run() {
635641
HasErrors = true;
636642
});
637643
}
644+
if (SrcIsCompilerBuiltins)
645+
HasLinkedCompilerBuiltins = true;
638646
if (HasErrors)
639647
return true;
640648

0 commit comments

Comments
 (0)