Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More General Statistics #686

Merged
merged 11 commits into from
Dec 12, 2023
97 changes: 73 additions & 24 deletions include/phasar/PhasarLLVM/Passes/GeneralStatisticsAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,107 +33,156 @@ class Module;

namespace psr {

class GeneralStatistics {
private:
friend class GeneralStatisticsAnalysis;
struct GeneralStatistics {

size_t Functions = 0;
size_t ExternalFunctions = 0;
size_t FunctionDefinitions = 0;
size_t AddressTakenFunctions = 0;
size_t Globals = 0;
size_t GlobalConsts = 0;
size_t ExternalGlobals = 0;
size_t GlobalsDefinitions = 0;
size_t BasicBlocks = 0;
size_t AllocationSites = 0;
size_t CallSites = 0;
size_t DebugIntrinsics = 0;
size_t Instructions = 0;
size_t StoreInstructions = 0;
size_t LoadInstructions = 0;
size_t MemIntrinsics = 0;
size_t GlobalPointers = 0;
size_t Branches = 0;
size_t Switches = 0;
size_t GetElementPtrs = 0;
size_t LandingPads = 0;
size_t PhiNodes = 0;
size_t GlobalConsts = 0;
size_t NumInlineAsm = 0;
size_t IndCalls = 0;
size_t TotalNumOperands = 0;
size_t TotalNumUses = 0;
size_t TotalNumPredecessorBBs = 0;
size_t TotalNumSuccessorBBs = 0;
size_t MaxNumOperands = 0;
size_t MaxNumUses = 0;
size_t MaxNumPredecessorBBs = 0;
size_t MaxNumSuccessorBBs = 0;
size_t NumInstWithMultipleUses = 0;
size_t NumInstsUsedOutsideBB = 0;
size_t NonVoidInsts = 0;
std::set<const llvm::Type *> AllocatedTypes;
std::set<const llvm::Instruction *> AllocaInstructions;
std::set<const llvm::Instruction *> RetResInstructions;
std::string ModuleName = "";
std::string ModuleName{};

public:
/**
* @brief Returns the number of Allocation sites.
*/
[[nodiscard]] size_t getAllocationsites() const;
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use AllocationSites instead")]] size_t
getAllocationsites() const;

/**
* @brief Returns the number of Function calls.
*/
[[nodiscard]] size_t getFunctioncalls() const;
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use CallSites instead")]] size_t
getFunctioncalls() const;

/**
* @brief Returns the number of Instructions.
*/
[[nodiscard]] size_t getInstructions() const;
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use Instructions instead")]] size_t
getInstructions() const;

/**
* @brief Returns the number of global pointers.
*/
[[nodiscard]] size_t getGlobalPointers() const;
[[nodiscard]] [[deprecated(
"All globals are pointers. Use Globals instead")]] size_t
getGlobalPointers() const;

/**
* @brief Returns the number of basic blocks.
*/
[[nodiscard]] size_t getBasicBlocks() const;
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use BasicBlocks instead")]] size_t
getBasicBlocks() const;

/**
* @brief Returns the number of functions.
*/
[[nodiscard]] size_t getFunctions() const;
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use Functions instead")]] size_t
getFunctions() const;

/**
* @brief Returns the number of globals.
*/
[[nodiscard]] size_t getGlobals() const;
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use Globals instead")]] size_t
getGlobals() const;

/**
* @brief Returns the number of constant globals.
*/
[[nodiscard]] size_t getGlobalConsts() const;
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use GlobalConsts instead")]] size_t
getGlobalConsts() const;

/**
* @brief Returns the number of memory intrinsics.
*/
[[nodiscard]] size_t getMemoryIntrinsics() const;
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use MemIntrinsics instead")]] size_t
getMemoryIntrinsics() const;

/**
* @brief Returns the number of store instructions.
*/
[[nodiscard]] size_t getStoreInstructions() const;
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use StoreInstructions instead")]] size_t
getStoreInstructions() const;

/**
* @brief Returns the number of load instructions.
*/
[[nodiscard]] size_t getLoadInstructions();
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use LoadInstructions instead; this "
"function seems to be broken anyway")]] size_t
getLoadInstructions();

/**
* @brief Returns all possible Types.
*/
[[nodiscard]] const std::set<const llvm::Type *> &getAllocatedTypes() const;
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use AllocatedTypes instead")]] const std::
set<const llvm::Type *> &
getAllocatedTypes() const;

/**
* @brief Returns all stack and heap allocating instructions.
*/
[[nodiscard]] const std::set<const llvm::Instruction *> &
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use AllocaInstructions "
"instead")]] const std::set<const llvm::Instruction *> &
getAllocaInstructions() const;

/**
* @brief Returns all Return and Resume Instructions.
*/
[[nodiscard]] const std::set<const llvm::Instruction *> &
[[nodiscard]] [[deprecated(
"Getters are no longer needed. Use RetResInstructions "
"instead")]] const std::set<const llvm::Instruction *> &
getRetResInstructions() const;

[[nodiscard]] nlohmann::json getAsJson() const;
void printAsJson(llvm::raw_ostream &OS = llvm::outs()) const;

friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const GeneralStatistics &Statistics);
};

llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const GeneralStatistics &Statistics);

/**
* This class uses the Module Pass Mechanism of LLVM to compute
* some statistics about a Module. This includes the number of
Expand Down
Loading
Loading