| 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): Create a more precise blacklist than this |
| 33 std::string FuncName = Func->getFunctionName().toStringOrEmpty(); |
| 34 if (FuncName.substr(0, 1) == "_" && FuncName != "_start") |
| 35 return; |
| 36 |
| 32 LoweringContext Context; | 37 LoweringContext Context; |
| 33 Context.init(Func->getNodes().front()); | 38 Context.init(Func->getNodes().front()); |
| 34 instrumentFuncStart(Context); | 39 instrumentFuncStart(Context); |
| 35 for (CfgNode *Node : Func->getNodes()) { | 40 for (CfgNode *Node : Func->getNodes()) { |
| 36 Context.init(Node); | 41 Context.init(Node); |
| 37 while (!Context.atEnd()) { | 42 while (!Context.atEnd()) { |
| 38 instrumentInst(Context); | 43 instrumentInst(Context); |
| 39 // go to next undeleted instruction | 44 // go to next undeleted instruction |
| 40 Context.advanceCur(); | 45 Context.advanceCur(); |
| 41 Context.advanceNext(); | 46 Context.advanceNext(); |
| 42 } | 47 } |
| 43 } | 48 } |
| 44 | 49 |
| 45 if (Func->getFunctionName().toStringOrEmpty() == "_start") | 50 if (FuncName == "_start") |
| 46 instrumentStart(Func); | 51 instrumentStart(Func); |
| 47 } | 52 } |
| 48 | 53 |
| 49 void Instrumentation::instrumentInst(LoweringContext &Context) { | 54 void Instrumentation::instrumentInst(LoweringContext &Context) { |
| 50 assert(!Context.atEnd()); | 55 assert(!Context.atEnd()); |
| 51 Inst *Instr = iteratorToInst(Context.getCur()); | 56 Inst *Instr = iteratorToInst(Context.getCur()); |
| 52 switch (Instr->getKind()) { | 57 switch (Instr->getKind()) { |
| 53 case Inst::Alloca: | 58 case Inst::Alloca: |
| 54 instrumentAlloca(Context, llvm::cast<InstAlloca>(Instr)); | 59 instrumentAlloca(Context, llvm::cast<InstAlloca>(Instr)); |
| 55 break; | 60 break; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 instrumentUnreachable(Context, llvm::cast<InstUnreachable>(Instr)); | 107 instrumentUnreachable(Context, llvm::cast<InstUnreachable>(Instr)); |
| 103 break; | 108 break; |
| 104 default: | 109 default: |
| 105 // Only instrument high-level ICE instructions | 110 // Only instrument high-level ICE instructions |
| 106 assert(false && "Instrumentation encountered an unexpected instruction"); | 111 assert(false && "Instrumentation encountered an unexpected instruction"); |
| 107 break; | 112 break; |
| 108 } | 113 } |
| 109 } | 114 } |
| 110 | 115 |
| 111 } // end of namespace Ice | 116 } // end of namespace Ice |
| OLD | NEW |