Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: src/IceLiveness.h

Issue 1844713004: Subzero: Ignore variables with no actual uses. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Also ignore rematerializable variables Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceInst.cpp ('k') | src/IceLiveness.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceLiveness.h - Liveness analysis ------------*- C++ -*-===// 1 //===- subzero/src/IceLiveness.h - Liveness analysis ------------*- 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 }; 60 };
61 61
62 public: 62 public:
63 Liveness(Cfg *Func, LivenessMode Mode) : Func(Func), Mode(Mode) {} 63 Liveness(Cfg *Func, LivenessMode Mode) : Func(Func), Mode(Mode) {}
64 void init(); 64 void init();
65 void initPhiEdgeSplits(NodeList::const_iterator FirstNode, 65 void initPhiEdgeSplits(NodeList::const_iterator FirstNode,
66 VarList::const_iterator FirstVar); 66 VarList::const_iterator FirstVar);
67 Cfg *getFunc() const { return Func; } 67 Cfg *getFunc() const { return Func; }
68 LivenessMode getMode() const { return Mode; } 68 LivenessMode getMode() const { return Mode; }
69 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const; 69 Variable *getVariable(SizeT LiveIndex, const CfgNode *Node) const;
70 SizeT getLiveIndex(SizeT VarIndex) const { return VarToLiveMap[VarIndex]; } 70 SizeT getLiveIndex(SizeT VarIndex) const {
71 const SizeT LiveIndex = VarToLiveMap[VarIndex];
72 assert(LiveIndex != InvalidLiveIndex);
73 return LiveIndex;
74 }
71 SizeT getNumGlobalVars() const { return NumGlobals; } 75 SizeT getNumGlobalVars() const { return NumGlobals; }
72 SizeT getNumVarsInNode(const CfgNode *Node) const { 76 SizeT getNumVarsInNode(const CfgNode *Node) const {
73 return NumGlobals + Nodes[Node->getIndex()].NumLocals; 77 return NumGlobals + Nodes[Node->getIndex()].NumLocals;
74 } 78 }
75 SizeT &getNumNonDeadPhis(const CfgNode *Node) { 79 SizeT &getNumNonDeadPhis(const CfgNode *Node) {
76 return Nodes[Node->getIndex()].NumNonDeadPhis; 80 return Nodes[Node->getIndex()].NumNonDeadPhis;
77 } 81 }
78 LivenessBV &getLiveIn(const CfgNode *Node) { 82 LivenessBV &getLiveIn(const CfgNode *Node) {
79 SizeT Index = Node->getIndex(); 83 SizeT Index = Node->getIndex();
80 resize(Index); 84 resize(Index);
(...skipping 18 matching lines...) Expand all
99 bool getRangeMask(SizeT Index) const { return RangeMask[Index]; } 103 bool getRangeMask(SizeT Index) const { return RangeMask[Index]; }
100 104
101 private: 105 private:
102 void initInternal(NodeList::const_iterator FirstNode, 106 void initInternal(NodeList::const_iterator FirstNode,
103 VarList::const_iterator FirstVar, bool IsFullInit); 107 VarList::const_iterator FirstVar, bool IsFullInit);
104 /// Resize Nodes so that Nodes[Index] is valid. 108 /// Resize Nodes so that Nodes[Index] is valid.
105 void resize(SizeT Index) { 109 void resize(SizeT Index) {
106 if (Index >= Nodes.size()) 110 if (Index >= Nodes.size())
107 Nodes.resize(Index + 1); 111 Nodes.resize(Index + 1);
108 } 112 }
113 static constexpr SizeT InvalidLiveIndex = -1;
109 Cfg *Func; 114 Cfg *Func;
110 LivenessMode Mode; 115 LivenessMode Mode;
111 SizeT NumGlobals = 0; 116 SizeT NumGlobals = 0;
112 /// Size of Nodes is Cfg::Nodes.size(). 117 /// Size of Nodes is Cfg::Nodes.size().
113 CfgVector<LivenessNode> Nodes; 118 CfgVector<LivenessNode> Nodes;
114 /// VarToLiveMap maps a Variable's Variable::Number to its live index within 119 /// VarToLiveMap maps a Variable's Variable::Number to its live index within
115 /// its basic block. 120 /// its basic block.
116 CfgVector<SizeT> VarToLiveMap; 121 CfgVector<SizeT> VarToLiveMap;
117 /// LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for non-local 122 /// LiveToVarMap is analogous to LivenessNode::LiveToVarMap, but for non-local
118 /// variables. 123 /// variables.
119 CfgVector<Variable *> LiveToVarMap; 124 CfgVector<Variable *> LiveToVarMap;
120 /// RangeMask[Variable::Number] indicates whether we want to track that 125 /// RangeMask[Variable::Number] indicates whether we want to track that
121 /// Variable's live range. 126 /// Variable's live range.
122 LivenessBV RangeMask; 127 LivenessBV RangeMask;
123 /// ScratchBV is a bitvector that can be reused across CfgNode passes, to 128 /// ScratchBV is a bitvector that can be reused across CfgNode passes, to
124 /// avoid having to allocate/deallocate memory so frequently. 129 /// avoid having to allocate/deallocate memory so frequently.
125 LivenessBV ScratchBV; 130 LivenessBV ScratchBV;
126 }; 131 };
127 132
128 } // end of namespace Ice 133 } // end of namespace Ice
129 134
130 #endif // SUBZERO_SRC_ICELIVENESS_H 135 #endif // SUBZERO_SRC_ICELIVENESS_H
OLDNEW
« no previous file with comments | « src/IceInst.cpp ('k') | src/IceLiveness.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698