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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include <condition_variable> | 26 #include <condition_variable> |
27 | 27 |
28 namespace Ice { | 28 namespace Ice { |
29 | 29 |
30 class ASanInstrumentation : public Instrumentation { | 30 class ASanInstrumentation : public Instrumentation { |
31 ASanInstrumentation() = delete; | 31 ASanInstrumentation() = delete; |
32 ASanInstrumentation(const ASanInstrumentation &) = delete; | 32 ASanInstrumentation(const ASanInstrumentation &) = delete; |
33 ASanInstrumentation &operator=(const ASanInstrumentation &) = delete; | 33 ASanInstrumentation &operator=(const ASanInstrumentation &) = delete; |
34 | 34 |
35 public: | 35 public: |
36 ASanInstrumentation(GlobalContext *Ctx) | 36 ASanInstrumentation(GlobalContext *Ctx) : Instrumentation(Ctx), RzNum(0) { |
37 : Instrumentation(Ctx), RzNum(0), | |
38 GlobalsLock(GlobalsMutex, std::defer_lock) { | |
39 ICE_TLS_INIT_FIELD(LocalDtors); | 37 ICE_TLS_INIT_FIELD(LocalDtors); |
40 } | 38 } |
41 void instrumentGlobals(VariableDeclarationList &Globals) override; | 39 void instrumentGlobals(VariableDeclarationList &Globals) override; |
42 | 40 |
43 private: | 41 private: |
44 std::string nextRzName(); | 42 std::string nextRzName(); |
45 bool isInstrumentable(Cfg *Func) override; | 43 bool isInstrumentable(Cfg *Func) override; |
46 void instrumentFuncStart(LoweringContext &Context) override; | 44 void instrumentFuncStart(LoweringContext &Context) override; |
47 void instrumentCall(LoweringContext &Context, InstCall *Instr) override; | 45 void instrumentCall(LoweringContext &Context, InstCall *Instr) override; |
48 void instrumentRet(LoweringContext &Context, InstRet *Instr) override; | 46 void instrumentRet(LoweringContext &Context, InstRet *Instr) override; |
49 void instrumentLoad(LoweringContext &Context, InstLoad *Instr) override; | 47 void instrumentLoad(LoweringContext &Context, InstLoad *Instr) override; |
50 void instrumentStore(LoweringContext &Context, InstStore *Instr) override; | 48 void instrumentStore(LoweringContext &Context, InstStore *Instr) override; |
51 void instrumentAccess(LoweringContext &Context, Operand *Op, SizeT Size, | 49 void instrumentAccess(LoweringContext &Context, Operand *Op, SizeT Size, |
52 Constant *AccessFunc); | 50 Constant *AccessFunc); |
53 void instrumentStart(Cfg *Func) override; | 51 void instrumentStart(Cfg *Func) override; |
54 void finishFunc(Cfg *Func) override; | 52 void finishFunc(Cfg *Func) override; |
55 ICE_TLS_DECLARE_FIELD(std::vector<InstCall *> *, LocalDtors); | 53 ICE_TLS_DECLARE_FIELD(std::vector<InstCall *> *, LocalDtors); |
56 std::atomic<uint32_t> RzNum; | 54 std::atomic<uint32_t> RzNum; |
57 bool DidProcessGlobals = false; | 55 bool DidProcessGlobals = false; |
58 SizeT RzGlobalsNum = 0; | 56 SizeT RzGlobalsNum = 0; |
59 std::mutex GlobalsMutex; | 57 std::mutex GlobalsMutex; |
60 std::unique_lock<std::mutex> GlobalsLock; | |
61 std::condition_variable GlobalsDoneCV; | |
62 }; | 58 }; |
63 } // end of namespace Ice | 59 } // end of namespace Ice |
64 | 60 |
65 #endif // SUBZERO_SRC_ICEASANINSTRUMENTATION_H | 61 #endif // SUBZERO_SRC_ICEASANINSTRUMENTATION_H |
OLD | NEW |