diff --git a/llvm/lib/Analysis/CFGPrinter.cpp b/llvm/lib/Analysis/CFGPrinter.cpp --- a/llvm/lib/Analysis/CFGPrinter.cpp +++ b/llvm/lib/Analysis/CFGPrinter.cpp @@ -96,6 +96,8 @@ } bool runOnFunction(Function &F) override { + if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName)) + return false; auto *BPI = &getAnalysis().getBPI(); auto *BFI = &getAnalysis().getBFI(); viewCFG(F, BFI, BPI, getMaxFreq(F, BFI)); @@ -118,6 +120,8 @@ true) PreservedAnalyses CFGViewerPass::run(Function &F, FunctionAnalysisManager &AM) { + if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName)) + return PreservedAnalyses::all(); auto *BFI = &AM.getResult(F); auto *BPI = &AM.getResult(F); viewCFG(F, BFI, BPI, getMaxFreq(F, BFI)); @@ -132,6 +136,8 @@ } bool runOnFunction(Function &F) override { + if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName)) + return false; auto *BPI = &getAnalysis().getBPI(); auto *BFI = &getAnalysis().getBFI(); viewCFG(F, BFI, BPI, getMaxFreq(F, BFI), /*CFGOnly=*/true); @@ -155,6 +161,8 @@ PreservedAnalyses CFGOnlyViewerPass::run(Function &F, FunctionAnalysisManager &AM) { + if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName)) + return PreservedAnalyses::all(); auto *BFI = &AM.getResult(F); auto *BPI = &AM.getResult(F); viewCFG(F, BFI, BPI, getMaxFreq(F, BFI), /*CFGOnly=*/true); @@ -169,6 +177,8 @@ } bool runOnFunction(Function &F) override { + if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName)) + return false; auto *BPI = &getAnalysis().getBPI(); auto *BFI = &getAnalysis().getBFI(); writeCFGToDotFile(F, BFI, BPI, getMaxFreq(F, BFI)); @@ -192,6 +202,8 @@ PreservedAnalyses CFGPrinterPass::run(Function &F, FunctionAnalysisManager &AM) { + if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName)) + return PreservedAnalyses::all(); auto *BFI = &AM.getResult(F); auto *BPI = &AM.getResult(F); writeCFGToDotFile(F, BFI, BPI, getMaxFreq(F, BFI)); @@ -206,6 +218,8 @@ } bool runOnFunction(Function &F) override { + if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName)) + return false; auto *BPI = &getAnalysis().getBPI(); auto *BFI = &getAnalysis().getBFI(); writeCFGToDotFile(F, BFI, BPI, getMaxFreq(F, BFI), /*CFGOnly=*/true); @@ -229,6 +243,8 @@ PreservedAnalyses CFGOnlyPrinterPass::run(Function &F, FunctionAnalysisManager &AM) { + if (!CFGFuncName.empty() && !F.getName().contains(CFGFuncName)) + return PreservedAnalyses::all(); auto *BFI = &AM.getResult(F); auto *BPI = &AM.getResult(F); writeCFGToDotFile(F, BFI, BPI, getMaxFreq(F, BFI), /*CFGOnly=*/true);