Chromium Code Reviews| Index: src/IceLiveness.h |
| diff --git a/src/IceLiveness.h b/src/IceLiveness.h |
| index 70578d42b518dcbd9bc2698049331f683865dfa3..a371bdc5e1e9d9ed9d2a95f74b8177b0346dfa57 100644 |
| --- a/src/IceLiveness.h |
| +++ b/src/IceLiveness.h |
| @@ -24,8 +24,12 @@ |
| #include "IceDefs.h" |
| #include "IceBitVector.h" |
| #include "IceCfgNode.h" |
| +#include "IceTLS.h" |
| #include "IceTypes.h" |
| +#include <memory> |
| +#include <utility> |
| + |
| namespace Ice { |
| class Liveness { |
| @@ -49,7 +53,7 @@ class Liveness { |
| // LiveToVarMap maps a liveness bitvector index to a Variable. This is |
| // generally just for printing/dumping. The index should be less than |
| // NumLocals + Liveness::NumGlobals. |
| - CfgVector<Variable *> LiveToVarMap; |
| + LivenessVector<Variable *> LiveToVarMap; |
| // LiveIn and LiveOut track the in- and out-liveness of the global |
| // variables. The size of each vector is LivenessNode::NumGlobals. |
| LivenessBV LiveIn, LiveOut; |
| @@ -60,7 +64,6 @@ class Liveness { |
| }; |
| public: |
| - Liveness(Cfg *Func, LivenessMode Mode) : Func(Func), Mode(Mode) {} |
| void init(); |
| void initPhiEdgeSplits(NodeList::const_iterator FirstNode, |
| VarList::const_iterator FirstVar); |
| @@ -98,25 +101,48 @@ public: |
| } |
| bool getRangeMask(SizeT Index) const { return RangeMask[Index]; } |
| + ArenaAllocator *getAllocator() const { return Alloc.get(); } |
| + |
| + static std::unique_ptr<Liveness> create(Cfg *Func, LivenessMode Mode) { |
| + return std::unique_ptr<Liveness>(new Liveness(Func, Mode)); |
| + } |
| + |
| + static void TlsInit() { LivenessAllocatorTraits::init(); } |
| + |
| + std::string dumpStr() const { |
| + return "MaxLocals(" + std::to_string(MaxLocals) + "), " |
| + "NumGlobals(" + |
| + std::to_string(NumGlobals) + ")"; |
| + } |
| + |
| private: |
| + SizeT MaxLocals = 0; |
|
Jim Stichnoth
2016/03/31 16:23:20
Should these data members be grouped with the othe
John
2016/04/01 13:52:04
Done.
|
| + SizeT NumGlobals = 0; |
| + |
| + Liveness(Cfg *Func, LivenessMode Mode) |
| + : Alloc(new ArenaAllocator()), AllocScope(this), Func(Func), Mode(Mode) {} |
| + |
| void initInternal(NodeList::const_iterator FirstNode, |
| VarList::const_iterator FirstVar, bool IsFullInit); |
| /// Resize Nodes so that Nodes[Index] is valid. |
| void resize(SizeT Index) { |
| - if (Index >= Nodes.size()) |
| + if (Index >= Nodes.size()) { |
| + assert(false); |
|
Jim Stichnoth
2016/03/31 16:23:20
I like this very much. What do you think about re
John
2016/04/01 13:52:04
I would expect the code to work correctly if the a
|
| Nodes.resize(Index + 1); |
| + } |
| } |
| + std::unique_ptr<ArenaAllocator> Alloc; |
| + LivenessAllocatorScope AllocScope; // Must be declared after Alloc. |
| Cfg *Func; |
| LivenessMode Mode; |
| - SizeT NumGlobals = 0; |
| /// Size of Nodes is Cfg::Nodes.size(). |
| - CfgVector<LivenessNode> Nodes; |
| + LivenessVector<LivenessNode> Nodes; |
| /// VarToLiveMap maps a Variable's Variable::Number to its live index within |
| /// its basic block. |
| - CfgVector<SizeT> VarToLiveMap; |
| + LivenessVector<SizeT> VarToLiveMap; |
| /// LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for non-local |
| /// variables. |
| - CfgVector<Variable *> LiveToVarMap; |
| + LivenessVector<Variable *> LiveToVarMap; |
| /// RangeMask[Variable::Number] indicates whether we want to track that |
| /// Variable's live range. |
| LivenessBV RangeMask; |