Skip to content

Commit 2371d0a

Browse files
authored
[DebugInfo] Only call upgradeCULocals() at module level (#68965)
Loading a 2GB bitcode file, I noticed that we spend minutes just running upgradeCULocals(). Apparently it gets invoked every time a metadata block is loaded, which will be once at the module level and then once per function. However, the relevant metadata only exists at the module level, so running this upgrade per function is unnecessary.
1 parent 5c09317 commit 2371d0a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llvm/lib/Bitcode/Reader/MetadataLoader.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -705,10 +705,11 @@ class MetadataLoader::MetadataLoaderImpl {
705705
return Error::success();
706706
}
707707

708-
void upgradeDebugInfo() {
708+
void upgradeDebugInfo(bool ModuleLevel) {
709709
upgradeCUSubprograms();
710710
upgradeCUVariables();
711-
upgradeCULocals();
711+
if (ModuleLevel)
712+
upgradeCULocals();
712713
}
713714

714715
void callMDTypeCallback(Metadata **Val, unsigned TypeID);
@@ -1085,7 +1086,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseMetadata(bool ModuleLevel) {
10851086
// Reading the named metadata created forward references and/or
10861087
// placeholders, that we flush here.
10871088
resolveForwardRefsAndPlaceholders(Placeholders);
1088-
upgradeDebugInfo();
1089+
upgradeDebugInfo(ModuleLevel);
10891090
// Return at the beginning of the block, since it is easy to skip it
10901091
// entirely from there.
10911092
Stream.ReadBlockEnd(); // Pop the abbrev block context.
@@ -1116,7 +1117,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseMetadata(bool ModuleLevel) {
11161117
return error("Malformed block");
11171118
case BitstreamEntry::EndBlock:
11181119
resolveForwardRefsAndPlaceholders(Placeholders);
1119-
upgradeDebugInfo();
1120+
upgradeDebugInfo(ModuleLevel);
11201121
return Error::success();
11211122
case BitstreamEntry::Record:
11221123
// The interesting case.

0 commit comments

Comments
 (0)