Skip to content

Commit 590a63b

Browse files
committed
Restrict COFF to a single thread when symbol count is high
1 parent 2d24155 commit 590a63b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/aotcompile.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ static FunctionInfo getFunctionWeight(const Function &F)
652652
}
653653

654654
struct ModuleInfo {
655+
Triple triple;
655656
size_t globals;
656657
size_t funcs;
657658
size_t bbs;
@@ -662,6 +663,7 @@ struct ModuleInfo {
662663

663664
ModuleInfo compute_module_info(Module &M) {
664665
ModuleInfo info;
666+
info.triple = Triple(M.getTargetTriple());
665667
info.globals = 0;
666668
info.funcs = 0;
667669
info.bbs = 0;
@@ -1413,6 +1415,13 @@ static unsigned compute_image_thread_count(const ModuleInfo &info) {
14131415
LLVM_DEBUG(dbgs() << "32-bit systems are restricted to a single thread\n");
14141416
return 1;
14151417
#endif
1418+
// COFF has limits on external symbols (even hidden) up to 65536. We reserve the last few
1419+
// for any of our other symbols that we insert during compilation.
1420+
if (info.triple.isOSBinFormatCOFF() && info.globals > 64000) {
1421+
LLVM_DEBUG(dbgs() << "COFF is restricted to a single thread for large images\n");
1422+
return 1;
1423+
}
1424+
14161425
// This is not overridable because empty modules do occasionally appear, but they'll be very small and thus exit early to
14171426
// known easy behavior. Plus they really don't warrant multiple threads
14181427
if (info.weight < 1000) {

0 commit comments

Comments
 (0)