 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
40.0% |
4 / 10 |
| Generated: |
2009-05-17 22:47 |
|
Branches Executed: |
60.0% |
6 / 10 |
| |
|
Line Coverage: |
100.0% |
13 / 13 |
| |
 |
|
 |
1 : //===- Executor.h - --*- C++ -*-===//
2 : //
3 : // Klee
4 : //
5 : //===---------------------------===//
6 : //
7 : // Classes which implement various klee-specific passes
8 : //
9 : //===--------------------------===//
10 :
11 : #ifndef KLEE_PASSES_H
12 : #define KLEE_PASSES_H
13 :
14 : #include "llvm/Constants.h"
15 : #include "llvm/Instructions.h"
16 : #include "llvm/Module.h"
17 : #include "llvm/Pass.h"
18 : #include "llvm/CodeGen/IntrinsicLowering.h"
19 :
20 : namespace llvm {
21 : class Function;
22 : class Instruction;
23 : class Module;
24 : class TargetData;
25 : class Type;
26 : }
27 :
28 : namespace klee {
29 :
30 : /// RaiseAsmPass - This pass raises some common occurences of inline
31 : /// asm which are used by glibc into normal LLVM IR.
103: branch 1 taken
0: branch 2 not taken
0: branch 5 not taken
0: branch 6 not taken
32 103: class RaiseAsmPass : public llvm::ModulePass {
33 : static char ID;
34 :
35 : llvm::Function *getIntrinsic(llvm::Module &M,
36 : unsigned IID,
37 : const llvm::Type **Tys,
38 : unsigned NumTys);
39 : llvm::Function *getIntrinsic(llvm::Module &M,
40 : unsigned IID,
41 : const llvm::Type *Ty0) {
42 1: return getIntrinsic(M, IID, &Ty0, 1);
43 : }
44 :
45 : bool runOnInstruction(llvm::Module &M, llvm::Instruction *I);
46 :
47 : public:
48 103: RaiseAsmPass() : llvm::ModulePass((intptr_t) &ID) {}
49 :
50 : virtual bool runOnModule(llvm::Module &M);
51 : };
52 :
53 : // This is a module pass because it can add and delete module
54 : // variables (via intrinsic lowering).
55 : class IntrinsicCleanerPass : public llvm::ModulePass {
56 : static char ID;
57 : llvm::IntrinsicLowering *IL;
58 : bool LowerIntrinsics;
59 :
60 : bool runOnBasicBlock(llvm::BasicBlock &b);
61 : public:
62 : IntrinsicCleanerPass(const llvm::TargetData &TD,
63 206: bool LI=true)
64 : : llvm::ModulePass((intptr_t) &ID),
65 : IL(new llvm::IntrinsicLowering(TD)),
66 412: LowerIntrinsics(LI) {}
206: branch 2 taken
67 206: ~IntrinsicCleanerPass() { delete IL; }
68 :
69 : virtual bool runOnModule(llvm::Module &M);
70 : };
71 :
72 : // performs two transformations which make interpretation
73 : // easier and faster.
74 : //
75 : // 1) Ensure that all the PHI nodes in a basic block have
76 : // the incoming block list in the same order. Thus the
77 : // incoming block index only needs to be computed once
78 : // for each transfer.
79 : //
80 : // 2) Ensure that no PHI node result is used as an argument to
81 : // a subsequent PHI node in the same basic block. This allows
82 : // the transfer to execute the instructions in order instead
83 : // of in two passes.
103: branch 1 taken
0: branch 2 not taken
0: branch 5 not taken
0: branch 6 not taken
84 103: class PhiCleanerPass : public llvm::FunctionPass {
85 : static char ID;
86 :
87 : public:
88 206: PhiCleanerPass() : llvm::FunctionPass((intptr_t) &ID) {}
89 :
90 : virtual bool runOnFunction(llvm::Function &f);
91 : };
92 :
103: branch 1 taken
93 103: class DivCheckPass : public llvm::ModulePass {
94 : static char ID;
95 : public:
96 103: DivCheckPass(): ModulePass((intptr_t) &ID) {}
97 : virtual bool runOnModule(llvm::Module &M);
98 : };
99 :
100 : /// LowerSwitchPass - Replace all SwitchInst instructions with chained branch
101 : /// instructions. Note that this cannot be a BasicBlock pass because it
102 : /// modifies the CFG!
103 1: class LowerSwitchPass : public llvm::FunctionPass {
104 : public:
105 : static char ID; // Pass identification, replacement for typeid
106 2: LowerSwitchPass() : FunctionPass((intptr_t) &ID) {}
107 :
108 : virtual bool runOnFunction(llvm::Function &F);
109 :
110 : struct SwitchCase {
111 : llvm ::Constant *value;
112 : llvm::BasicBlock *block;
113 :
114 : SwitchCase() : value(0), block(0) { }
115 : SwitchCase(llvm::Constant *v, llvm::BasicBlock *b) :
116 70: value(v), block(b) { }
117 : };
118 :
119 : typedef std::vector<SwitchCase> CaseVector;
120 : typedef std::vector<SwitchCase>::iterator CaseItr;
121 :
122 : private:
123 : void processSwitchInst(llvm::SwitchInst *SI);
124 : void switchConvert(CaseItr begin,
125 : CaseItr end,
126 : llvm::Value *value,
127 : llvm::BasicBlock *origBlock,
128 : llvm::BasicBlock *defaultBlock);
129 : };
130 :
131 : }
132 :
133 : #endif
Generated: 2009-05-17 22:47 by zcov