Skip to content

Commit eb4416b

Browse files
Restrict COFF to a single thread when symbol count is high (#50874)
1 parent 2c0e1d8 commit eb4416b

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
@@ -651,6 +651,7 @@ static FunctionInfo getFunctionWeight(const Function &F)
651651
}
652652

653653
struct ModuleInfo {
654+
Triple triple;
654655
size_t globals;
655656
size_t funcs;
656657
size_t bbs;
@@ -661,6 +662,7 @@ struct ModuleInfo {
661662

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

0 commit comments

Comments
 (0)