From 1bbbdebc9efbfe5c2796db41cdfed1fb2d655653 Mon Sep 17 00:00:00 2001 From: Andrzej Warzynski Date: Sat, 17 Jul 2021 19:13:16 +0100 Subject: [PATCH] Fix #39 Background and solution identical to the previous patch. --- README.md | 2 +- include/StaticCallCounter.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b72a2ef6..ea5fcdef 100644 --- a/README.md +++ b/README.md @@ -440,7 +440,7 @@ to test **StaticCallCounter**: ```bash export LLVM_DIR= # Generate an LLVM file to analyze -$LLVM_DIR/bin/clang -O1 -emit-llvm -c /inputs/input_for_cc.c -o input_for_cc.bc +$LLVM_DIR/bin/clang -emit-llvm -c /inputs/input_for_cc.c -o input_for_cc.bc # Run the pass through opt - Legacy PM $LLVM_DIR/bin/opt -load /lib/libStaticCallCounter.so -legacy-static-cc -analyze input_for_cc.bc ``` diff --git a/include/StaticCallCounter.h b/include/StaticCallCounter.h index 7575aa3f..8d7551c4 100644 --- a/include/StaticCallCounter.h +++ b/include/StaticCallCounter.h @@ -29,6 +29,9 @@ struct StaticCallCounter : public llvm::AnalysisInfoMixin { using Result = ResultStaticCC; Result run(llvm::Module &M, llvm::ModuleAnalysisManager &); Result runOnModule(llvm::Module &M); + // Part of the official API: + // https://llvm.org/docs/WritingAnLLVMNewPMPass.html#required-passes + static bool isRequired() { return true; } private: // A special type used by analysis passes to provide an address that @@ -46,6 +49,9 @@ class StaticCallCounterPrinter explicit StaticCallCounterPrinter(llvm::raw_ostream &OutS) : OS(OutS) {} llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &MAM); + // Part of the official API: + // https://llvm.org/docs/WritingAnLLVMNewPMPass.html#required-passes + static bool isRequired() { return true; } private: llvm::raw_ostream &OS;