Chromium Code Reviews| 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 | |
| 33 // represents user accessibility more and library accessibility less. | |
| 34 std::string FuncName = Func->getFunctionName().toStringOrEmpty(); | |
| 32 LoweringContext Context; | 35 LoweringContext Context; | 
| 33 Context.init(Func->getNodes().front()); | 36 Context.init(Func->getNodes().front()); | 
| 34 instrumentFuncStart(Context); | 37 instrumentFuncStart(Context); | 
| 35 for (CfgNode *Node : Func->getNodes()) { | 38 for (CfgNode *Node : Func->getNodes()) { | 
| 36 Context.init(Node); | 39 Context.init(Node); | 
| 37 while (!Context.atEnd()) { | 40 while (!Context.atEnd()) { | 
| 38 instrumentInst(Context); | 41 instrumentInst(Context); | 
| 39 // go to next undeleted instruction | 42 // go to next undeleted instruction | 
| 40 Context.advanceCur(); | 43 Context.advanceCur(); | 
| 41 Context.advanceNext(); | 44 Context.advanceNext(); | 
| 42 } | 45 } | 
| 43 } | 46 } | 
| 44 | 47 | 
| 45 if (Func->getFunctionName().toStringOrEmpty() == "_start") | 48 if (FuncName == "_start") | 
| 
 
Karl
2016/06/17 22:04:11
Move declaration of FuncName here.
 
tlively
2016/06/17 23:03:58
Done.
 
 | |
| 46 instrumentStart(Func); | 49 instrumentStart(Func); | 
| 47 } | 50 } | 
| 48 | 51 | 
| 49 void Instrumentation::instrumentInst(LoweringContext &Context) { | 52 void Instrumentation::instrumentInst(LoweringContext &Context) { | 
| 50 assert(!Context.atEnd()); | 53 assert(!Context.atEnd()); | 
| 51 Inst *Instr = iteratorToInst(Context.getCur()); | 54 Inst *Instr = iteratorToInst(Context.getCur()); | 
| 52 switch (Instr->getKind()) { | 55 switch (Instr->getKind()) { | 
| 53 case Inst::Alloca: | 56 case Inst::Alloca: | 
| 54 instrumentAlloca(Context, llvm::cast<InstAlloca>(Instr)); | 57 instrumentAlloca(Context, llvm::cast<InstAlloca>(Instr)); | 
| 55 break; | 58 break; | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 instrumentUnreachable(Context, llvm::cast<InstUnreachable>(Instr)); | 105 instrumentUnreachable(Context, llvm::cast<InstUnreachable>(Instr)); | 
| 103 break; | 106 break; | 
| 104 default: | 107 default: | 
| 105 // Only instrument high-level ICE instructions | 108 // Only instrument high-level ICE instructions | 
| 106 assert(false && "Instrumentation encountered an unexpected instruction"); | 109 assert(false && "Instrumentation encountered an unexpected instruction"); | 
| 107 break; | 110 break; | 
| 108 } | 111 } | 
| 109 } | 112 } | 
| 110 | 113 | 
| 111 } // end of namespace Ice | 114 } // end of namespace Ice | 
| OLD | NEW |