@@ -1450,123 +1450,127 @@ static void performParallelIRGeneration(IRGenDescriptor desc) {
1450
1450
IGM->addLinkLibraries ();
1451
1451
IGMcreated = true ;
1452
1452
}
1453
-
1453
+
1454
1454
if (!IGMcreated) {
1455
1455
// TODO: Check this already at argument parsing.
1456
1456
Ctx.Diags .diagnose (SourceLoc (), diag::no_input_files_for_mt);
1457
1457
return ;
1458
1458
}
1459
1459
1460
- // Emit the module contents.
1461
- irgen. emitGlobalTopLevel (desc. getLinkerDirectives () );
1460
+ {
1461
+ FrontendStatsTracer tracer (Ctx. Stats , " IRGen " );
1462
1462
1463
- for (auto *File : M->getFiles ()) {
1464
- if (auto *SF = dyn_cast<SourceFile>(File)) {
1465
- {
1466
- CurrentIGMPtr IGM = irgen.getGenModule (SF);
1467
- IGM->emitSourceFile (*SF);
1468
- }
1469
-
1470
- if (auto *synthSFU = File->getSynthesizedFile ()) {
1471
- CurrentIGMPtr IGM = irgen.getGenModule (synthSFU);
1472
- IGM->emitSynthesizedFileUnit (*synthSFU);
1463
+ // Emit the module contents.
1464
+ irgen.emitGlobalTopLevel (desc.getLinkerDirectives ());
1465
+
1466
+ for (auto *File : M->getFiles ()) {
1467
+ if (auto *SF = dyn_cast<SourceFile>(File)) {
1468
+ {
1469
+ CurrentIGMPtr IGM = irgen.getGenModule (SF);
1470
+ IGM->emitSourceFile (*SF);
1471
+ }
1472
+
1473
+ if (auto *synthSFU = File->getSynthesizedFile ()) {
1474
+ CurrentIGMPtr IGM = irgen.getGenModule (synthSFU);
1475
+ IGM->emitSynthesizedFileUnit (*synthSFU);
1476
+ }
1473
1477
}
1474
1478
}
1475
- }
1476
-
1477
- // Okay, emit any definitions that we suddenly need.
1478
- irgen.emitLazyDefinitions ();
1479
1479
1480
- irgen.emitSwiftProtocols ();
1480
+ // Okay, emit any definitions that we suddenly need.
1481
+ irgen.emitLazyDefinitions ();
1482
+
1483
+ irgen.emitSwiftProtocols ();
1481
1484
1482
- irgen.emitDynamicReplacements ();
1485
+ irgen.emitDynamicReplacements ();
1483
1486
1484
- irgen.emitProtocolConformances ();
1487
+ irgen.emitProtocolConformances ();
1485
1488
1486
- irgen.emitTypeMetadataRecords ();
1489
+ irgen.emitTypeMetadataRecords ();
1487
1490
1488
- irgen.emitAccessibleFunctions ();
1491
+ irgen.emitAccessibleFunctions ();
1489
1492
1490
- irgen.emitReflectionMetadataVersion ();
1493
+ irgen.emitReflectionMetadataVersion ();
1491
1494
1492
- irgen.emitEagerClassInitialization ();
1493
- irgen.emitObjCActorsNeedingSuperclassSwizzle ();
1495
+ irgen.emitEagerClassInitialization ();
1496
+ irgen.emitObjCActorsNeedingSuperclassSwizzle ();
1494
1497
1495
- // Emit reflection metadata for builtin and imported types.
1496
- irgen.emitBuiltinReflectionMetadata ();
1498
+ // Emit reflection metadata for builtin and imported types.
1499
+ irgen.emitBuiltinReflectionMetadata ();
1500
+
1501
+ // Emit coverage mapping info. This needs to happen after we've emitted
1502
+ // any lazy definitions, as we need to know whether or not we emitted a
1503
+ // profiler increment for a given coverage map.
1504
+ irgen.emitCoverageMapping ();
1497
1505
1498
- // Emit coverage mapping info. This needs to happen after we've emitted
1499
- // any lazy definitions, as we need to know whether or not we emitted a
1500
- // profiler increment for a given coverage map.
1501
- irgen.emitCoverageMapping ();
1506
+ IRGenModule *PrimaryGM = irgen.getPrimaryIGM ();
1502
1507
1503
- IRGenModule *PrimaryGM = irgen.getPrimaryIGM ();
1508
+ // Emit symbols for eliminated dead methods.
1509
+ PrimaryGM->emitVTableStubs ();
1504
1510
1505
- // Emit symbols for eliminated dead methods.
1506
- PrimaryGM->emitVTableStubs ();
1511
+ // Verify type layout if we were asked to.
1512
+ if (!Opts.VerifyTypeLayoutNames .empty ())
1513
+ PrimaryGM->emitTypeVerifier ();
1507
1514
1508
- // Verify type layout if we were asked to.
1509
- if (!Opts.VerifyTypeLayoutNames .empty ())
1510
- PrimaryGM->emitTypeVerifier ();
1511
-
1512
- std::for_each (Opts.LinkLibraries .begin (), Opts.LinkLibraries .end (),
1513
- [&](LinkLibrary linkLib) {
1514
- PrimaryGM->addLinkLibrary (linkLib);
1515
- });
1516
-
1517
- llvm::DenseSet<StringRef> referencedGlobals;
1518
-
1519
- for (auto it = irgen.begin (); it != irgen.end (); ++it) {
1520
- IRGenModule *IGM = it->second ;
1521
- llvm::Module *M = IGM->getModule ();
1522
- auto collectReference = [&](llvm::GlobalValue &G) {
1523
- if (G.isDeclaration ()
1524
- && (G.getLinkage () == GlobalValue::LinkOnceODRLinkage ||
1525
- G.getLinkage () == GlobalValue::ExternalLinkage)) {
1526
- referencedGlobals.insert (G.getName ());
1527
- G.setLinkage (GlobalValue::ExternalLinkage);
1515
+ std::for_each (Opts.LinkLibraries .begin (), Opts.LinkLibraries .end (),
1516
+ [&](LinkLibrary linkLib) {
1517
+ PrimaryGM->addLinkLibrary (linkLib);
1518
+ });
1519
+
1520
+ llvm::DenseSet<StringRef> referencedGlobals;
1521
+
1522
+ for (auto it = irgen.begin (); it != irgen.end (); ++it) {
1523
+ IRGenModule *IGM = it->second ;
1524
+ llvm::Module *M = IGM->getModule ();
1525
+ auto collectReference = [&](llvm::GlobalValue &G) {
1526
+ if (G.isDeclaration ()
1527
+ && (G.getLinkage () == GlobalValue::LinkOnceODRLinkage ||
1528
+ G.getLinkage () == GlobalValue::ExternalLinkage)) {
1529
+ referencedGlobals.insert (G.getName ());
1530
+ G.setLinkage (GlobalValue::ExternalLinkage);
1531
+ }
1532
+ };
1533
+ for (llvm::GlobalVariable &G : M->globals ()) {
1534
+ collectReference (G);
1535
+ }
1536
+ for (llvm::Function &F : M->getFunctionList ()) {
1537
+ collectReference (F);
1538
+ }
1539
+ for (llvm::GlobalAlias &A : M->aliases ()) {
1540
+ collectReference (A);
1528
1541
}
1529
- };
1530
- for (llvm::GlobalVariable &G : M->globals ()) {
1531
- collectReference (G);
1532
- }
1533
- for (llvm::Function &F : M->getFunctionList ()) {
1534
- collectReference (F);
1535
- }
1536
- for (llvm::GlobalAlias &A : M->aliases ()) {
1537
- collectReference (A);
1538
1542
}
1539
- }
1540
1543
1541
- for (auto it = irgen.begin (); it != irgen.end (); ++it) {
1542
- IRGenModule *IGM = it->second ;
1543
- llvm::Module *M = IGM->getModule ();
1544
-
1545
- // Update the linkage of shared functions/globals.
1546
- // If a shared function/global is referenced from another file it must have
1547
- // weak instead of linkonce linkage. Otherwise LLVM would remove the
1548
- // definition (if it's not referenced in the same file).
1549
- auto updateLinkage = [&](llvm::GlobalValue &G) {
1550
- if (!G.isDeclaration ()
1551
- && G.getLinkage () == GlobalValue::LinkOnceODRLinkage
1552
- && referencedGlobals.count (G.getName ()) != 0 ) {
1553
- G.setLinkage (GlobalValue::WeakODRLinkage);
1544
+ for (auto it = irgen.begin (); it != irgen.end (); ++it) {
1545
+ IRGenModule *IGM = it->second ;
1546
+ llvm::Module *M = IGM->getModule ();
1547
+
1548
+ // Update the linkage of shared functions/globals.
1549
+ // If a shared function/global is referenced from another file it must have
1550
+ // weak instead of linkonce linkage. Otherwise LLVM would remove the
1551
+ // definition (if it's not referenced in the same file).
1552
+ auto updateLinkage = [&](llvm::GlobalValue &G) {
1553
+ if (!G.isDeclaration ()
1554
+ && G.getLinkage () == GlobalValue::LinkOnceODRLinkage
1555
+ && referencedGlobals.count (G.getName ()) != 0 ) {
1556
+ G.setLinkage (GlobalValue::WeakODRLinkage);
1557
+ }
1558
+ };
1559
+ for (llvm::GlobalVariable &G : M->globals ()) {
1560
+ updateLinkage (G);
1561
+ }
1562
+ for (llvm::Function &F : M->getFunctionList ()) {
1563
+ updateLinkage (F);
1564
+ }
1565
+ for (llvm::GlobalAlias &A : M->aliases ()) {
1566
+ updateLinkage (A);
1554
1567
}
1555
- };
1556
- for (llvm::GlobalVariable &G : M->globals ()) {
1557
- updateLinkage (G);
1558
- }
1559
- for (llvm::Function &F : M->getFunctionList ()) {
1560
- updateLinkage (F);
1561
- }
1562
- for (llvm::GlobalAlias &A : M->aliases ()) {
1563
- updateLinkage (A);
1564
- }
1565
1568
1566
- if (!IGM->finalize ())
1567
- return ;
1569
+ if (!IGM->finalize ())
1570
+ return ;
1568
1571
1569
- setModuleFlags (*IGM);
1572
+ setModuleFlags (*IGM);
1573
+ }
1570
1574
}
1571
1575
1572
1576
// Bail out if there are any errors.
0 commit comments