OLD | NEW |
1 //===- subzero/src/IceInstrumentation.cpp - ICE instrumentation framework -===// | 1 //===- subzero/src/IceInstrumentation.cpp - ICE instrumentation framework -===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "IceTargetLowering.h" | 22 #include "IceTargetLowering.h" |
23 | 23 |
24 namespace Ice { | 24 namespace Ice { |
25 | 25 |
26 // Iterate through the instructions in the given CFG and instrument each one. | 26 // Iterate through the instructions in the given CFG and instrument each one. |
27 // Also instrument the beginning of the function. | 27 // Also instrument the beginning of the function. |
28 void Instrumentation::instrumentFunc(Cfg *Func) { | 28 void Instrumentation::instrumentFunc(Cfg *Func) { |
29 assert(Func); | 29 assert(Func); |
30 assert(!Func->getNodes().empty()); | 30 assert(!Func->getNodes().empty()); |
31 | 31 |
32 // TODO(tlively): More selectively instrument functions so that shadow memory | 32 if (!isInstrumentable(Func)) |
33 // represents user accessibility more and library accessibility less. | 33 return; |
34 bool DidInstrumentStart = false; | 34 |
| 35 bool DidInstrumentEntry = false; |
35 LoweringContext Context; | 36 LoweringContext Context; |
36 Context.init(Func->getNodes().front()); | 37 Context.init(Func->getNodes().front()); |
37 for (CfgNode *Node : Func->getNodes()) { | 38 for (CfgNode *Node : Func->getNodes()) { |
38 Context.init(Node); | 39 Context.init(Node); |
39 while (!Context.atEnd()) { | 40 while (!Context.atEnd()) { |
40 if (!DidInstrumentStart) { | 41 if (!DidInstrumentEntry) { |
41 instrumentFuncStart(Context); | 42 instrumentFuncStart(Context); |
42 DidInstrumentStart = true; | 43 DidInstrumentEntry = true; |
43 } | 44 } |
44 instrumentInst(Context); | 45 instrumentInst(Context); |
45 // go to next undeleted instruction | 46 // go to next undeleted instruction |
46 Context.advanceCur(); | 47 Context.advanceCur(); |
47 Context.advanceNext(); | 48 Context.advanceNext(); |
48 } | 49 } |
49 } | 50 } |
50 | 51 |
51 std::string FuncName = Func->getFunctionName().toStringOrEmpty(); | 52 std::string FuncName = Func->getFunctionName().toStringOrEmpty(); |
52 if (FuncName == "_start") | 53 if (FuncName == "_start") |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 instrumentUnreachable(Context, llvm::cast<InstUnreachable>(Instr)); | 112 instrumentUnreachable(Context, llvm::cast<InstUnreachable>(Instr)); |
112 break; | 113 break; |
113 default: | 114 default: |
114 // Only instrument high-level ICE instructions | 115 // Only instrument high-level ICE instructions |
115 assert(false && "Instrumentation encountered an unexpected instruction"); | 116 assert(false && "Instrumentation encountered an unexpected instruction"); |
116 break; | 117 break; |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
120 } // end of namespace Ice | 121 } // end of namespace Ice |
OLD | NEW |