Skip to content

Commit

Permalink
LLVM Statistics handling (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahueck authored Jan 3, 2022
1 parent c63197e commit 57bd61f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/passes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ add_library(typeart::TransformPass ALIAS ${TYPEART_PREFIX}_TransformPass)

target_compile_definitions(
${TYPEART_PREFIX}_TransformPass PRIVATE LOG_LEVEL=${LOG_LEVEL}
$<$<BOOL:${SHOW_STATS}>:LLVM_ENABLE_STATS>
$<$<BOOL:${SHOW_STATS}>:LLVM_FORCE_ENABLE_STATS=1>
)

target_project_compile_options(${TYPEART_PREFIX}_TransformPass)
Expand Down
12 changes: 6 additions & 6 deletions lib/passes/TypeARTPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ cl::opt<bool> ClCallFilterDeep("call-filter-deep",
cl::opt<bool> ClFilterPointerStack("typeart-filter-pointer-alloca", cl::desc("Filter allocas of pointers."), cl::Hidden,
cl::init(true));

STATISTIC(NumInstrumentedMallocs, "Number of instrumented mallocs");
STATISTIC(NumInstrumentedFrees, "Number of instrumented frees");
STATISTIC(NumInstrumentedAlloca, "Number of instrumented (stack) allocas");
STATISTIC(NumInstrumentedGlobal, "Number of instrumented globals");
ALWAYS_ENABLED_STATISTIC(NumInstrumentedMallocs, "Number of instrumented mallocs");
ALWAYS_ENABLED_STATISTIC(NumInstrumentedFrees, "Number of instrumented frees");
ALWAYS_ENABLED_STATISTIC(NumInstrumentedAlloca, "Number of instrumented (stack) allocas");
ALWAYS_ENABLED_STATISTIC(NumInstrumentedGlobal, "Number of instrumented globals");

namespace typeart::pass {

Expand All @@ -120,7 +120,7 @@ TypeArtPass::TypeArtPass() : llvm::ModulePass(ID) {
ClCallFilterCGFile}};
meminst_finder = analysis::create_finder(conf);

EnableStatistics();
EnableStatistics(false);
}

void TypeArtPass::getAnalysisUsage(llvm::AnalysisUsage& info) const {
Expand Down Expand Up @@ -228,7 +228,7 @@ bool TypeArtPass::doFinalization(Module&) {
} else {
LOG_FATAL("Failed writing type config to " << ClTypeFile.getValue() << ". Reason: " << error.message());
}
if (ClTypeArtStats && AreStatisticsEnabled()) {
if (ClTypeArtStats) {
auto& out = llvm::errs();
printStats(out);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/passes/analysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ target_link_libraries(${TYPEART_PREFIX}_MemInstFinder PUBLIC typeart::MemOpFilte

target_compile_options(${TYPEART_PREFIX}_MemInstFinder PRIVATE "-fno-rtti")

target_compile_definitions(${TYPEART_PREFIX}_MemInstFinder PRIVATE LOG_LEVEL=${LOG_LEVEL})
target_compile_definitions(
${TYPEART_PREFIX}_MemInstFinder PRIVATE LOG_LEVEL=${LOG_LEVEL}
$<$<BOOL:${SHOW_STATS}>:LLVM_FORCE_ENABLE_STATS=1>
)

set_target_properties(${TYPEART_PREFIX}_MemInstFinder PROPERTIES POSITION_INDEPENDENT_CODE ON)

Expand Down
20 changes: 10 additions & 10 deletions lib/passes/analysis/MemInstFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@
using namespace llvm;

#define DEBUG_TYPE "MemInstFinder"
STATISTIC(NumDetectedHeap, "Number of detected heap allocs");
STATISTIC(NumFilteredDetectedHeap, "Number of filtered heap allocs");
STATISTIC(NumDetectedAllocs, "Number of detected allocs");
STATISTIC(NumFilteredPointerAllocs, "Number of filtered pointer allocs");
STATISTIC(NumCallFilteredAllocs, "Number of call filtered allocs");
STATISTIC(NumFilteredMallocAllocs, "Number of filtered malloc-related allocs");
STATISTIC(NumFilteredNonArrayAllocs, "Number of filtered non-array allocs");
STATISTIC(NumDetectedGlobals, "Number of detected globals");
STATISTIC(NumFilteredGlobals, "Number of filtered globals");
STATISTIC(NumCallFilteredGlobals, "Number of filtered globals");
ALWAYS_ENABLED_STATISTIC(NumDetectedHeap, "Number of detected heap allocs");
ALWAYS_ENABLED_STATISTIC(NumFilteredDetectedHeap, "Number of filtered heap allocs");
ALWAYS_ENABLED_STATISTIC(NumDetectedAllocs, "Number of detected allocs");
ALWAYS_ENABLED_STATISTIC(NumFilteredPointerAllocs, "Number of filtered pointer allocs");
ALWAYS_ENABLED_STATISTIC(NumCallFilteredAllocs, "Number of call filtered allocs");
ALWAYS_ENABLED_STATISTIC(NumFilteredMallocAllocs, "Number of filtered malloc-related allocs");
ALWAYS_ENABLED_STATISTIC(NumFilteredNonArrayAllocs, "Number of filtered non-array allocs");
ALWAYS_ENABLED_STATISTIC(NumDetectedGlobals, "Number of detected globals");
ALWAYS_ENABLED_STATISTIC(NumFilteredGlobals, "Number of filtered globals");
ALWAYS_ENABLED_STATISTIC(NumCallFilteredGlobals, "Number of filtered globals");

namespace typeart::analysis {

Expand Down

0 comments on commit 57bd61f

Please sign in to comment.