Skip to content

Commit 51cdf1f

Browse files
[memprof] Skip MemProfUsePass on the empty module (llvm#117210)
This patch teaches the MemProfUsePass to return immediately on the empty module. Aside from saving time to deserialize the MemProf profile, this patch ensures that we can obtain TLI like so: TargetLibraryInfo &TLI = FAM.getResult<TargetLibraryAnalysis>(*M.begin()); when we undrift the MemProf profile in near future.
1 parent 30df659 commit 51cdf1f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

llvm/lib/Transforms/Instrumentation/MemProfiler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,10 @@ MemProfUsePass::MemProfUsePass(std::string MemoryProfileFile,
11211121
}
11221122

11231123
PreservedAnalyses MemProfUsePass::run(Module &M, ModuleAnalysisManager &AM) {
1124+
// Return immediately if the module doesn't contain any function.
1125+
if (M.empty())
1126+
return PreservedAnalyses::all();
1127+
11241128
LLVM_DEBUG(dbgs() << "Read in memory profile:");
11251129
auto &Ctx = M.getContext();
11261130
auto ReaderOrErr = IndexedInstrProfReader::create(MemoryProfileFileName, *FS);

0 commit comments

Comments
 (0)