| OLD | NEW |
| 1 //===- subzero/src/IceASanInstrumentation.h - AddressSanitizer --*- C++ -*-===// | 1 //===- subzero/src/IceASanInstrumentation.h - AddressSanitizer --*- C++ -*-===// |
| 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 |
| 11 /// \brief Declares the AddressSanitizer instrumentation class. | 11 /// \brief Declares the AddressSanitizer instrumentation class. |
| 12 /// | 12 /// |
| 13 /// This class is responsible for inserting redzones around global and stack | 13 /// This class is responsible for inserting redzones around global and stack |
| 14 /// variables, inserting code responsible for poisoning those redzones, and | 14 /// variables, inserting code responsible for poisoning those redzones, and |
| 15 /// performing any other instrumentation necessary to implement | 15 /// performing any other instrumentation necessary to implement |
| 16 /// AddressSanitizer. | 16 /// AddressSanitizer. |
| 17 /// | 17 /// |
| 18 //===----------------------------------------------------------------------===// | 18 //===----------------------------------------------------------------------===// |
| 19 | 19 |
| 20 #ifndef SUBZERO_SRC_ICEASANINSTRUMENTATION_H | 20 #ifndef SUBZERO_SRC_ICEASANINSTRUMENTATION_H |
| 21 #define SUBZERO_SRC_ICEASANINSTRUMENTATION_H | 21 #define SUBZERO_SRC_ICEASANINSTRUMENTATION_H |
| 22 | 22 |
| 23 #include "IceGlobalInits.h" | 23 #include "IceGlobalInits.h" |
| 24 #include "IceInstrumentation.h" | 24 #include "IceInstrumentation.h" |
| 25 | 25 |
| 26 namespace Ice { | 26 namespace Ice { |
| 27 | 27 |
| 28 using VarSizeMap = std::unordered_map<Operand *, SizeT>; |
| 29 |
| 28 class ASanInstrumentation : public Instrumentation { | 30 class ASanInstrumentation : public Instrumentation { |
| 29 ASanInstrumentation() = delete; | 31 ASanInstrumentation() = delete; |
| 30 ASanInstrumentation(const ASanInstrumentation &) = delete; | 32 ASanInstrumentation(const ASanInstrumentation &) = delete; |
| 31 ASanInstrumentation &operator=(const ASanInstrumentation &) = delete; | 33 ASanInstrumentation &operator=(const ASanInstrumentation &) = delete; |
| 32 | 34 |
| 33 public: | 35 public: |
| 34 ASanInstrumentation(GlobalContext *Ctx) : Instrumentation(Ctx), RzNum(0) { | 36 ASanInstrumentation(GlobalContext *Ctx) : Instrumentation(Ctx), RzNum(0) { |
| 37 ICE_TLS_INIT_FIELD(LocalVars); |
| 35 ICE_TLS_INIT_FIELD(LocalDtors); | 38 ICE_TLS_INIT_FIELD(LocalDtors); |
| 36 } | 39 } |
| 37 void instrumentGlobals(VariableDeclarationList &Globals) override; | 40 void instrumentGlobals(VariableDeclarationList &Globals) override; |
| 38 | 41 |
| 39 private: | 42 private: |
| 40 std::string nextRzName(); | 43 std::string nextRzName(); |
| 41 bool isInstrumentable(Cfg *Func) override; | 44 bool isInstrumentable(Cfg *Func) override; |
| 42 void instrumentFuncStart(LoweringContext &Context) override; | 45 void instrumentFuncStart(LoweringContext &Context) override; |
| 43 void instrumentCall(LoweringContext &Context, InstCall *Instr) override; | 46 void instrumentCall(LoweringContext &Context, InstCall *Instr) override; |
| 44 void instrumentRet(LoweringContext &Context, InstRet *Instr) override; | 47 void instrumentRet(LoweringContext &Context, InstRet *Instr) override; |
| 45 void instrumentLoad(LoweringContext &Context, InstLoad *Instr) override; | 48 void instrumentLoad(LoweringContext &Context, InstLoad *Instr) override; |
| 46 void instrumentStore(LoweringContext &Context, InstStore *Instr) override; | 49 void instrumentStore(LoweringContext &Context, InstStore *Instr) override; |
| 47 void instrumentAccess(LoweringContext &Context, Operand *Op, SizeT Size, | 50 void instrumentAccess(LoweringContext &Context, Operand *Op, SizeT Size, |
| 48 Constant *AccessFunc); | 51 Constant *AccessFunc); |
| 49 void instrumentStart(Cfg *Func) override; | 52 void instrumentStart(Cfg *Func) override; |
| 50 void finishFunc(Cfg *Func) override; | 53 void finishFunc(Cfg *Func) override; |
| 54 ICE_TLS_DECLARE_FIELD(VarSizeMap *, LocalVars); |
| 51 ICE_TLS_DECLARE_FIELD(std::vector<InstCall *> *, LocalDtors); | 55 ICE_TLS_DECLARE_FIELD(std::vector<InstCall *> *, LocalDtors); |
| 52 std::atomic<uint32_t> RzNum; | 56 std::atomic<uint32_t> RzNum; |
| 53 bool DidProcessGlobals = false; | 57 bool DidProcessGlobals = false; |
| 54 SizeT RzGlobalsNum = 0; | 58 SizeT RzGlobalsNum = 0; |
| 55 std::mutex GlobalsMutex; | 59 std::mutex GlobalsMutex; |
| 56 }; | 60 }; |
| 57 } // end of namespace Ice | 61 } // end of namespace Ice |
| 58 | 62 |
| 59 #endif // SUBZERO_SRC_ICEASANINSTRUMENTATION_H | 63 #endif // SUBZERO_SRC_ICEASANINSTRUMENTATION_H |
| OLD | NEW |