Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Analysis/InstCount.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- InstCount.cpp - Collects the count of all instructions ------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This pass collects the count of all instructions and reports them
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/ADT/Statistic.h"
14
#include "llvm/Analysis/Passes.h"
15
#include "llvm/IR/Function.h"
16
#include "llvm/IR/InstVisitor.h"
17
#include "llvm/Pass.h"
18
#include "llvm/Support/Debug.h"
19
#include "llvm/Support/ErrorHandling.h"
20
#include "llvm/Support/raw_ostream.h"
21
using namespace llvm;
22
23
#define DEBUG_TYPE "instcount"
24
25
STATISTIC(TotalInsts , "Number of instructions (of all types)");
26
STATISTIC(TotalBlocks, "Number of basic blocks");
27
STATISTIC(TotalFuncs , "Number of non-external functions");
28
29
#define HANDLE_INST(N, OPCODE, CLASS) \
30
  STATISTIC(Num ## OPCODE ## Inst, "Number of " #OPCODE " insts");
31
32
#include "llvm/IR/Instruction.def"
33
34
namespace {
35
  class InstCount : public FunctionPass, public InstVisitor<InstCount> {
36
    friend class InstVisitor<InstCount>;
37
38
0
    void visitFunction  (Function &F) { ++TotalFuncs; }
39
0
    void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; }
40
41
#define HANDLE_INST(N, OPCODE, CLASS) \
42
0
    void visit##OPCODE(CLASS &) { ++Num##OPCODE##Inst; ++TotalInsts; }
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitRet(llvm::ReturnInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitBr(llvm::BranchInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitSwitch(llvm::SwitchInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitIndirectBr(llvm::IndirectBrInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitInvoke(llvm::InvokeInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitResume(llvm::ResumeInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitUnreachable(llvm::UnreachableInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitCleanupRet(llvm::CleanupReturnInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitCatchRet(llvm::CatchReturnInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitCatchSwitch(llvm::CatchSwitchInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitCallBr(llvm::CallBrInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFNeg(llvm::UnaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitAdd(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFAdd(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitSub(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFSub(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitMul(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFMul(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitUDiv(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitSDiv(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFDiv(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitURem(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitSRem(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFRem(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitShl(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitLShr(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitAShr(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitAnd(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitOr(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitXor(llvm::BinaryOperator&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitAlloca(llvm::AllocaInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitLoad(llvm::LoadInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitStore(llvm::StoreInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitGetElementPtr(llvm::GetElementPtrInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFence(llvm::FenceInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitAtomicCmpXchg(llvm::AtomicCmpXchgInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitAtomicRMW(llvm::AtomicRMWInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitTrunc(llvm::TruncInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitZExt(llvm::ZExtInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitSExt(llvm::SExtInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFPToUI(llvm::FPToUIInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFPToSI(llvm::FPToSIInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitUIToFP(llvm::UIToFPInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitSIToFP(llvm::SIToFPInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFPTrunc(llvm::FPTruncInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFPExt(llvm::FPExtInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitPtrToInt(llvm::PtrToIntInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitIntToPtr(llvm::IntToPtrInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitBitCast(llvm::BitCastInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitAddrSpaceCast(llvm::AddrSpaceCastInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitCleanupPad(llvm::CleanupPadInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitCatchPad(llvm::CatchPadInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitICmp(llvm::ICmpInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitFCmp(llvm::FCmpInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitPHI(llvm::PHINode&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitCall(llvm::CallInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitSelect(llvm::SelectInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitUserOp1(llvm::Instruction&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitUserOp2(llvm::Instruction&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitVAArg(llvm::VAArgInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitExtractElement(llvm::ExtractElementInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitInsertElement(llvm::InsertElementInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitShuffleVector(llvm::ShuffleVectorInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitExtractValue(llvm::ExtractValueInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitInsertValue(llvm::InsertValueInst&)
Unexecuted instantiation: InstCount.cpp:(anonymous namespace)::InstCount::visitLandingPad(llvm::LandingPadInst&)
43
44
#include "llvm/IR/Instruction.def"
45
46
0
    void visitInstruction(Instruction &I) {
47
0
      errs() << "Instruction Count does not know about " << I;
48
0
      llvm_unreachable(nullptr);
49
0
    }
50
  public:
51
    static char ID; // Pass identification, replacement for typeid
52
0
    InstCount() : FunctionPass(ID) {
53
0
      initializeInstCountPass(*PassRegistry::getPassRegistry());
54
0
    }
55
56
    bool runOnFunction(Function &F) override;
57
58
0
    void getAnalysisUsage(AnalysisUsage &AU) const override {
59
0
      AU.setPreservesAll();
60
0
    }
61
0
    void print(raw_ostream &O, const Module *M) const override {}
62
63
  };
64
}
65
66
char InstCount::ID = 0;
67
INITIALIZE_PASS(InstCount, "instcount",
68
                "Counts the various types of Instructions", false, true)
69
70
0
FunctionPass *llvm::createInstCountPass() { return new InstCount(); }
71
72
// InstCount::run - This is the main Analysis entry point for a
73
// function.
74
//
75
0
bool InstCount::runOnFunction(Function &F) {
76
0
  visit(F);
77
0
  return false;
78
0
}