@@ -1570,6 +1570,7 @@ class DwarfLinker {
1570
1570
1571
1571
// / Clear compile units and ranges.
1572
1572
void Clear () {
1573
+ DwarfContext.reset (nullptr );
1573
1574
CompileUnits.clear ();
1574
1575
Ranges.clear ();
1575
1576
}
@@ -1605,7 +1606,7 @@ class DwarfLinker {
1605
1606
OffsetsStringPool &OffsetsStringPool,
1606
1607
UniquingStringPool &UniquingStringPoolStringPool,
1607
1608
DeclContextTree &ODRContexts, unsigned &UnitID,
1608
- unsigned Indent = 0 );
1609
+ unsigned Indent = 0 , bool Quiet = false );
1609
1610
1610
1611
// / Recursively add the debug info in this clang module .pcm
1611
1612
// / file (and all the modules imported by it in a bottom-up fashion)
@@ -1616,7 +1617,7 @@ class DwarfLinker {
1616
1617
RangesTy &Ranges, OffsetsStringPool &OffsetsStringPool,
1617
1618
UniquingStringPool &UniquingStringPool,
1618
1619
DeclContextTree &ODRContexts, unsigned &UnitID,
1619
- unsigned Indent = 0 );
1620
+ unsigned Indent = 0 , bool Quiet = false );
1620
1621
1621
1622
// / Flags passed to DwarfLinker::lookForDIEsToKeep
1622
1623
enum TravesalFlags {
@@ -3900,7 +3901,7 @@ bool DwarfLinker::registerModuleReference(
3900
3901
const DWARFDie &CUDie, const DWARFUnit &Unit, DebugMap &ModuleMap,
3901
3902
const DebugMapObject &DMO, RangesTy &Ranges, OffsetsStringPool &StringPool,
3902
3903
UniquingStringPool &UniquingStringPool, DeclContextTree &ODRContexts,
3903
- unsigned &UnitID, unsigned Indent) {
3904
+ unsigned &UnitID, unsigned Indent, bool Quiet ) {
3904
3905
std::string PCMfile = dwarf::toString (
3905
3906
CUDie.find ({dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}), " " );
3906
3907
if (PCMfile.empty ())
@@ -3912,11 +3913,12 @@ bool DwarfLinker::registerModuleReference(
3912
3913
3913
3914
std::string Name = dwarf::toString (CUDie.find (dwarf::DW_AT_name), " " );
3914
3915
if (Name.empty ()) {
3915
- reportWarning (" Anonymous module skeleton CU for " + PCMfile, DMO);
3916
+ if (!Quiet)
3917
+ reportWarning (" Anonymous module skeleton CU for " + PCMfile, DMO);
3916
3918
return true ;
3917
3919
}
3918
3920
3919
- if (Options.Verbose ) {
3921
+ if (!Quiet && Options.Verbose ) {
3920
3922
outs ().indent (Indent);
3921
3923
outs () << " Found clang module reference " << PCMfile;
3922
3924
}
@@ -3926,24 +3928,24 @@ bool DwarfLinker::registerModuleReference(
3926
3928
// FIXME: Until PR27449 (https://llvm.org/bugs/show_bug.cgi?id=27449) is
3927
3929
// fixed in clang, only warn about DWO_id mismatches in verbose mode.
3928
3930
// ASTFileSignatures will change randomly when a module is rebuilt.
3929
- if (Options.Verbose && (Cached->second != DwoId))
3931
+ if (!Quiet && Options.Verbose && (Cached->second != DwoId))
3930
3932
reportWarning (Twine (" hash mismatch: this object file was built against a "
3931
3933
" different version of the module " ) +
3932
3934
PCMfile,
3933
3935
DMO);
3934
- if (Options.Verbose )
3936
+ if (!Quiet && Options.Verbose )
3935
3937
outs () << " [cached].\n " ;
3936
3938
return true ;
3937
3939
}
3938
- if (Options.Verbose )
3940
+ if (!Quiet && Options.Verbose )
3939
3941
outs () << " ...\n " ;
3940
3942
3941
3943
// Cyclic dependencies are disallowed by Clang, but we still
3942
3944
// shouldn't run into an infinite loop, so mark it as processed now.
3943
3945
ClangModules.insert ({PCMfile, DwoId});
3944
3946
if (Error E = loadClangModule (PCMfile, PCMpath, Name, DwoId, ModuleMap, DMO,
3945
3947
Ranges, StringPool, UniquingStringPool,
3946
- ODRContexts, UnitID, Indent + 2 )) {
3948
+ ODRContexts, UnitID, Indent + 2 , Quiet )) {
3947
3949
consumeError (std::move (E));
3948
3950
return false ;
3949
3951
}
@@ -3965,14 +3967,12 @@ DwarfLinker::loadObject(BinaryHolder &BinaryHolder, const DebugMapObject &Obj,
3965
3967
return ErrOrObj;
3966
3968
}
3967
3969
3968
- Error DwarfLinker::loadClangModule (StringRef Filename, StringRef ModulePath,
3969
- StringRef ModuleName, uint64_t DwoId,
3970
- DebugMap &ModuleMap,
3971
- const DebugMapObject &DMO, RangesTy &Ranges,
3972
- OffsetsStringPool &StringPool,
3973
- UniquingStringPool &UniquingStringPool,
3974
- DeclContextTree &ODRContexts,
3975
- unsigned &UnitID, unsigned Indent) {
3970
+ Error DwarfLinker::loadClangModule (
3971
+ StringRef Filename, StringRef ModulePath, StringRef ModuleName,
3972
+ uint64_t DwoId, DebugMap &ModuleMap, const DebugMapObject &DMO,
3973
+ RangesTy &Ranges, OffsetsStringPool &StringPool,
3974
+ UniquingStringPool &UniquingStringPool, DeclContextTree &ODRContexts,
3975
+ unsigned &UnitID, unsigned Indent, bool Quiet) {
3976
3976
SmallString<80 > Path (Options.PrependPath );
3977
3977
if (sys::path::is_relative (Filename))
3978
3978
sys::path::append (Path, ModulePath, Filename);
@@ -4030,7 +4030,7 @@ Error DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath,
4030
4030
auto CUDie = CU->getUnitDIE (false );
4031
4031
if (!registerModuleReference (CUDie, *CU, ModuleMap, DMO, Ranges, StringPool,
4032
4032
UniquingStringPool, ODRContexts, UnitID,
4033
- Indent)) {
4033
+ Indent, Quiet )) {
4034
4034
if (Unit) {
4035
4035
std::string Err =
4036
4036
(Filename +
@@ -4044,7 +4044,7 @@ Error DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath,
4044
4044
// ASTFileSignatures will change randomly when a module is rebuilt.
4045
4045
uint64_t PCMDwoId = getDwoId (CUDie, *CU);
4046
4046
if (PCMDwoId != DwoId) {
4047
- if (Options.Verbose )
4047
+ if (!Quiet && Options.Verbose )
4048
4048
reportWarning (
4049
4049
Twine (" hash mismatch: this object file was built against a "
4050
4050
" different version of the module " ) +
@@ -4066,7 +4066,7 @@ Error DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath,
4066
4066
}
4067
4067
if (!Unit->getOrigUnit ().getUnitDIE ().hasChildren ())
4068
4068
return Error::success ();
4069
- if (Options.Verbose ) {
4069
+ if (!Quiet && Options.Verbose ) {
4070
4070
outs ().indent (Indent);
4071
4071
outs () << " cloning .debug_info from " << Filename << " \n " ;
4072
4072
}
@@ -4289,12 +4289,10 @@ bool DwarfLinker::link(const DebugMap &Map) {
4289
4289
CUDie.dump (outs (), 0 , DumpOpts);
4290
4290
}
4291
4291
4292
- if (!CUDie || LLVM_UNLIKELY (Options.Update ) ||
4293
- !registerModuleReference (CUDie, *CU, ModuleMap, LinkContext.DMO ,
4294
- LinkContext.Ranges , OffsetsStringPool,
4295
- UniquingStringPool, ODRContexts, UnitID)) {
4296
- LinkContext.CompileUnits .push_back (llvm::make_unique<CompileUnit>(
4297
- *CU, UnitID++, !Options.NoODR && !Options.Update , " " ));
4292
+ if (CUDie && !LLVM_UNLIKELY (Options.Update )) {
4293
+ registerModuleReference (CUDie, *CU, ModuleMap, LinkContext.DMO ,
4294
+ LinkContext.Ranges , OffsetsStringPool,
4295
+ UniquingStringPool, ODRContexts, UnitID);
4298
4296
maybeUpdateMaxDwarfVersion (CU->getVersion ());
4299
4297
}
4300
4298
}
@@ -4316,13 +4314,31 @@ bool DwarfLinker::link(const DebugMap &Map) {
4316
4314
for (unsigned i = 0 , e = NumObjects; i != e; ++i) {
4317
4315
auto &LinkContext = ObjectContexts[i];
4318
4316
4319
- if (!LinkContext.ObjectFile ) {
4317
+ if (!LinkContext.ObjectFile || !LinkContext. DwarfContext ) {
4320
4318
std::unique_lock<std::mutex> LockGuard (ProcessedFilesMutex);
4321
4319
ProcessedFiles.set (i);
4322
4320
ProcessedFilesConditionVariable.notify_one ();
4323
4321
continue ;
4324
4322
}
4325
4323
4324
+ for (const auto &CU : LinkContext.DwarfContext ->compile_units ()) {
4325
+ // The !registerModuleReference() condition effectively skips
4326
+ // over fully resolved skeleton units. This second pass of
4327
+ // registerModuleReferences doesn't do any new work, but it
4328
+ // will collect top-level errors, which are suppressed. Module
4329
+ // warnings were already displayed in the first iteration.
4330
+ bool Quiet = true ;
4331
+ auto CUDie = CU->getUnitDIE (false );
4332
+ if (!CUDie || LLVM_UNLIKELY (Options.Update ) ||
4333
+ !registerModuleReference (CUDie, *CU, ModuleMap, LinkContext.DMO ,
4334
+ LinkContext.Ranges , OffsetsStringPool,
4335
+ UniquingStringPool, ODRContexts, UnitID,
4336
+ Quiet)) {
4337
+ LinkContext.CompileUnits .push_back (llvm::make_unique<CompileUnit>(
4338
+ *CU, UnitID++, !Options.NoODR && !Options.Update , " " ));
4339
+ }
4340
+ }
4341
+
4326
4342
// Now build the DIE parent links that we will use during the next phase.
4327
4343
for (auto &CurrentUnit : LinkContext.CompileUnits )
4328
4344
analyzeContextInfo (CurrentUnit->getOrigUnit ().getUnitDIE (), 0 ,
0 commit comments