Commit c28e27be2b9649c39970d0e8b731be2b99ed7a29
1 parent
ed83c12e26
Exists in
master
Reduce Compile Errors
Showing 1 changed file with 20 additions and 15 deletions Side-by-side Diff
llvm/src/lib/CSE231/WorkList.cpp
View file @
c28e27b
... | ... | @@ -8,57 +8,62 @@ |
8 | 8 | #include "llvm/IR/Module.h" |
9 | 9 | #include "llvm/IR/Instruction.h" |
10 | 10 | #include "llvm/Pass.h" |
11 | -#include "llvm/Support/raw_ostream.h" | |
12 | -#include "llvm/Support/InstIterator.h" | |
11 | +#include "llvm/ADT/StringRef.h" | |
12 | +#include "llvm/ADT/STLExtras.h" | |
13 | +#include <list> | |
14 | +#include <map> | |
15 | +#include <string> | |
16 | +#include <set> | |
13 | 17 | using namespace llvm; |
14 | 18 | namespace{ |
15 | 19 | class Edge{ |
16 | 20 | public: |
17 | 21 | BasicBlock *BB; |
18 | 22 | Instruction *IB; |
19 | - bool isBlock(false); | |
20 | - bool isInstruction(false); | |
21 | -} | |
23 | + bool isBlock; | |
24 | + bool isInstruction; | |
25 | + Edge() : isBlock(false), isInstruction(false) { } | |
26 | +}; | |
22 | 27 | class CPElement{ |
23 | 28 | public: |
24 | 29 | //The variable |
25 | - String variable; | |
30 | + StringRef variable; | |
26 | 31 | //the value it holds |
27 | 32 | int value; |
28 | -} | |
33 | +}; | |
29 | 34 | |
30 | -void Worklist(Function *F) | |
35 | +void Worklist(Function *FB) | |
31 | 36 | { |
32 | 37 | SmallVector<Edge*,256> WorkList; |
33 | 38 | |
34 | 39 | //Map of Edge(Basic Block/Instruction) to computed value |
35 | - std::map<Edge*, std::set<CPElement> M; | |
40 | + std::map<Edge*, std::set<CPElement> > M; | |
36 | 41 | //And its iterator |
37 | 42 | std::map<Edge*, std::set<CPElement>::iterator MI; |
38 | 43 | |
39 | 44 | //Null Element to initialize edge mappings |
40 | - CPElement ElementNull = new CPElement(); | |
41 | - | |
42 | - ElementNull.variable = new String("phi"); | |
45 | + CPElement ElementNull; | |
46 | + ElementNull.variable = "phi"; | |
43 | 47 | ElementNull.value = -1; |
44 | 48 | |
45 | 49 | //For every BasicBlock |
46 | 50 | //Add them to the Map |
47 | 51 | //And store ElementNull as their value |
48 | 52 | for(Function::iterator BB = FB->begin(), BE = FB->end(); BB != BE; ++BB) { |
49 | - Edge BasicBlockEdge = new Edge(); | |
53 | + Edge BasicBlockEdge; | |
50 | 54 | BasicBlockEdge.isBlock = true; |
51 | 55 | BasicBlockEdge.BB = BB; |
52 | - M[BasicBlockEdge] = ElementNull | |
56 | + M[BasicBlockEdge] = ElementNull; | |
53 | 57 | for (BasicBlock::iterator IB = BB->begin(), IE = BB->end();IB != IE; ++IB) { |
54 | 58 | //For every InstructionBlock |
55 | 59 | //Add them to the Map |
56 | 60 | //And store ElementNull as their value |
57 | - Edge InstructionEdge = new Edge(); | |
61 | + Edge InstructionEdge; | |
58 | 62 | InstructionEdge.isInstruction = true; |
59 | 63 | InstructionEdge.IB = IB; |
60 | 64 | M[InstructionEdge] = ElementNull; |
61 | 65 | } |
62 | 66 | } |
67 | +} | |
63 | 68 | } |