@@ -371,27 +371,26 @@ Error DWARFLinkerImpl::LinkContext::loadClangModule(
371
371
372
372
Error DWARFLinkerImpl::LinkContext::link () {
373
373
InterCUProcessingStarted = false ;
374
- if (InputDWARFFile.Warnings .empty ()) {
375
- if (!InputDWARFFile.Dwarf )
376
- return Error::success ();
374
+ if (!InputDWARFFile.Dwarf )
375
+ return Error::success ();
377
376
378
- // Preload macro tables, as they can't be loaded asynchronously.
379
- InputDWARFFile.Dwarf ->getDebugMacinfo ();
380
- InputDWARFFile.Dwarf ->getDebugMacro ();
377
+ // Preload macro tables, as they can't be loaded asynchronously.
378
+ InputDWARFFile.Dwarf ->getDebugMacinfo ();
379
+ InputDWARFFile.Dwarf ->getDebugMacro ();
381
380
382
- // Link modules compile units first.
383
- parallelForEach (ModulesCompileUnits, [&](RefModuleUnit &RefModule) {
384
- linkSingleCompileUnit (*RefModule.Unit );
385
- });
381
+ // Link modules compile units first.
382
+ parallelForEach (ModulesCompileUnits, [&](RefModuleUnit &RefModule) {
383
+ linkSingleCompileUnit (*RefModule.Unit );
384
+ });
386
385
387
- // Check for live relocations. If there is no any live relocation then we
388
- // can skip entire object file.
389
- if (!GlobalData.getOptions ().UpdateIndexTablesOnly &&
390
- !InputDWARFFile.Addresses ->hasValidRelocs ()) {
391
- if (GlobalData.getOptions ().Verbose )
392
- outs () << " No valid relocations found. Skipping.\n " ;
393
- return Error::success ();
394
- }
386
+ // Check for live relocations. If there is no any live relocation then we
387
+ // can skip entire object file.
388
+ if (!GlobalData.getOptions ().UpdateIndexTablesOnly &&
389
+ !InputDWARFFile.Addresses ->hasValidRelocs ()) {
390
+ if (GlobalData.getOptions ().Verbose )
391
+ outs () << " No valid relocations found. Skipping.\n " ;
392
+ return Error::success ();
393
+ }
395
394
396
395
OriginalDebugInfoSize = getInputDebugInfoSize ();
397
396
@@ -460,21 +459,8 @@ Error DWARFLinkerImpl::LinkContext::link() {
460
459
linkSingleCompileUnit (*CU, CompileUnit::Stage::Cleaned);
461
460
});
462
461
}
463
- }
464
462
465
- if (!InputDWARFFile.Warnings .empty ()) {
466
- // Create compile unit with paper trail warnings.
467
-
468
- Error ResultErr = Error::success ();
469
- // We use task group here as PerThreadBumpPtrAllocator should be called from
470
- // the threads created by ThreadPoolExecutor.
471
- parallel::TaskGroup TGroup;
472
- TGroup.spawn ([&]() {
473
- if (Error Err = cloneAndEmitPaperTrails ())
474
- ResultErr = std::move (Err);
475
- });
476
- return ResultErr;
477
- } else if (GlobalData.getOptions ().UpdateIndexTablesOnly ) {
463
+ if (GlobalData.getOptions ().UpdateIndexTablesOnly ) {
478
464
// Emit Invariant sections.
479
465
480
466
if (Error Err = emitInvariantSections ())
@@ -715,102 +701,6 @@ void DWARFLinkerImpl::LinkContext::emitFDE(uint32_t CIEOffset,
715
701
Section.OS .write (FDEBytes.data (), FDEBytes.size ());
716
702
}
717
703
718
- Error DWARFLinkerImpl::LinkContext::cloneAndEmitPaperTrails () {
719
- CompileUnits.emplace_back (std::make_unique<CompileUnit>(
720
- GlobalData, UniqueUnitID.fetch_add (1 ), " " , InputDWARFFile,
721
- getUnitForOffset, Format, Endianness));
722
-
723
- CompileUnit &CU = *CompileUnits.back ();
724
-
725
- BumpPtrAllocator Allocator;
726
-
727
- DIEGenerator ParentGenerator (Allocator, CU);
728
-
729
- SectionDescriptor &DebugInfoSection =
730
- CU.getOrCreateSectionDescriptor (DebugSectionKind::DebugInfo);
731
- OffsetsPtrVector PatchesOffsets;
732
-
733
- uint64_t CurrentOffset = CU.getDebugInfoHeaderSize ();
734
- DIE *CUDie =
735
- ParentGenerator.createDIE (dwarf::DW_TAG_compile_unit, CurrentOffset);
736
- CU.setOutUnitDIE (CUDie);
737
-
738
- DebugInfoSection.notePatchWithOffsetUpdate (
739
- DebugStrPatch{{CurrentOffset},
740
- GlobalData.getStringPool ().insert (" dsymutil" ).first },
741
- PatchesOffsets);
742
- CurrentOffset += ParentGenerator
743
- .addStringPlaceholderAttribute (dwarf::DW_AT_producer,
744
- dwarf::DW_FORM_strp)
745
- .second ;
746
-
747
- CurrentOffset +=
748
- ParentGenerator
749
- .addInplaceString (dwarf::DW_AT_name, InputDWARFFile.FileName )
750
- .second ;
751
-
752
- size_t SizeAbbrevNumber = ParentGenerator.finalizeAbbreviations (true );
753
- CurrentOffset += SizeAbbrevNumber;
754
- for (uint64_t *OffsetPtr : PatchesOffsets)
755
- *OffsetPtr += SizeAbbrevNumber;
756
- for (const auto &Warning : CU.getContaingFile ().Warnings ) {
757
- PatchesOffsets.clear ();
758
- DIEGenerator ChildGenerator (Allocator, CU);
759
-
760
- DIE *ChildDie =
761
- ChildGenerator.createDIE (dwarf::DW_TAG_constant, CurrentOffset);
762
- ParentGenerator.addChild (ChildDie);
763
-
764
- DebugInfoSection.notePatchWithOffsetUpdate (
765
- DebugStrPatch{
766
- {CurrentOffset},
767
- GlobalData.getStringPool ().insert (" dsymutil_warning" ).first },
768
- PatchesOffsets);
769
- CurrentOffset += ChildGenerator
770
- .addStringPlaceholderAttribute (dwarf::DW_AT_name,
771
- dwarf::DW_FORM_strp)
772
- .second ;
773
-
774
- CurrentOffset +=
775
- ChildGenerator
776
- .addScalarAttribute (dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1 )
777
- .second ;
778
-
779
- DebugInfoSection.notePatchWithOffsetUpdate (
780
- DebugStrPatch{{CurrentOffset},
781
- GlobalData.getStringPool ().insert (Warning).first },
782
- PatchesOffsets);
783
- CurrentOffset += ChildGenerator
784
- .addStringPlaceholderAttribute (
785
- dwarf::DW_AT_const_value, dwarf::DW_FORM_strp)
786
- .second ;
787
-
788
- SizeAbbrevNumber = ChildGenerator.finalizeAbbreviations (false );
789
-
790
- CurrentOffset += SizeAbbrevNumber;
791
- for (uint64_t *OffsetPtr : PatchesOffsets)
792
- *OffsetPtr += SizeAbbrevNumber;
793
-
794
- ChildDie->setSize (CurrentOffset - ChildDie->getOffset ());
795
- }
796
-
797
- CurrentOffset += 1 ; // End of children
798
- CUDie->setSize (CurrentOffset - CUDie->getOffset ());
799
-
800
- uint64_t UnitSize = 0 ;
801
- UnitSize += CU.getDebugInfoHeaderSize ();
802
- UnitSize += CUDie->getSize ();
803
- CU.setUnitSize (UnitSize);
804
-
805
- if (GlobalData.getOptions ().NoOutput )
806
- return Error::success ();
807
-
808
- if (Error Err = CU.emitDebugInfo (*TargetTriple))
809
- return Err;
810
-
811
- return CU.emitAbbreviations ();
812
- }
813
-
814
704
void DWARFLinkerImpl::glueCompileUnitsAndWriteToTheOutput () {
815
705
if (GlobalData.getOptions ().NoOutput )
816
706
return ;
0 commit comments