Skip to content

Commit e025ccb

Browse files
pchintalapudinalimilan
authored andcommitted
Restrict COFF to a single thread when symbol count is high (#50874)
(cherry picked from commit eb4416b)
1 parent 90f0cb4 commit e025ccb

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

652652
struct ModuleInfo {
653+
Triple triple;
653654
size_t globals;
654655
size_t funcs;
655656
size_t bbs;
@@ -660,6 +661,7 @@ struct ModuleInfo {
660661

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

0 commit comments

Comments
 (0)