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

Side by Side Diff: src/IceCfg.cpp

Issue 1838973005: Subzero. Liveness memory management. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments. 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/IceBitVector.h ('k') | src/IceDefs.h » ('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/IceCfg.cpp - Control flow graph implementation ---------===// 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===//
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 10 matching lines...) Expand all
21 #include "IceDefs.h" 21 #include "IceDefs.h"
22 #include "IceELFObjectWriter.h" 22 #include "IceELFObjectWriter.h"
23 #include "IceGlobalInits.h" 23 #include "IceGlobalInits.h"
24 #include "IceInst.h" 24 #include "IceInst.h"
25 #include "IceInstVarIter.h" 25 #include "IceInstVarIter.h"
26 #include "IceLiveness.h" 26 #include "IceLiveness.h"
27 #include "IceLoopAnalyzer.h" 27 #include "IceLoopAnalyzer.h"
28 #include "IceOperand.h" 28 #include "IceOperand.h"
29 #include "IceTargetLowering.h" 29 #include "IceTargetLowering.h"
30 30
31 #include <memory>
32 #include <utility>
33
31 namespace Ice { 34 namespace Ice {
32 35
33 Cfg::Cfg(GlobalContext *Ctx, uint32_t SequenceNumber) 36 Cfg::Cfg(GlobalContext *Ctx, uint32_t SequenceNumber)
34 : Ctx(Ctx), SequenceNumber(SequenceNumber), 37 : Ctx(Ctx), SequenceNumber(SequenceNumber),
35 VMask(Ctx->getFlags().getVerbose()), FunctionName(), 38 VMask(Ctx->getFlags().getVerbose()), FunctionName(),
36 NextInstNumber(Inst::NumberInitial), Live(nullptr) { 39 NextInstNumber(Inst::NumberInitial), Live(nullptr) {
37 Allocator.reset(new ArenaAllocator()); 40 Allocator.reset(new ArenaAllocator());
38 NodeStrings.reset(new StringPool); 41 NodeStrings.reset(new StringPool);
39 VarStrings.reset(new StringPool); 42 VarStrings.reset(new StringPool);
40 CfgLocalAllocatorScope _(this); 43 CfgLocalAllocatorScope _(this);
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 // convergence. 815 // convergence.
813 void Cfg::livenessLightweight() { 816 void Cfg::livenessLightweight() {
814 TimerMarker T(TimerStack::TT_livenessLightweight, this); 817 TimerMarker T(TimerStack::TT_livenessLightweight, this);
815 getVMetadata()->init(VMK_Uses); 818 getVMetadata()->init(VMK_Uses);
816 for (CfgNode *Node : Nodes) 819 for (CfgNode *Node : Nodes)
817 Node->livenessLightweight(); 820 Node->livenessLightweight();
818 } 821 }
819 822
820 void Cfg::liveness(LivenessMode Mode) { 823 void Cfg::liveness(LivenessMode Mode) {
821 TimerMarker T(TimerStack::TT_liveness, this); 824 TimerMarker T(TimerStack::TT_liveness, this);
822 Live.reset(new Liveness(this, Mode)); 825 // Destroying the previous (if any) Liveness information clears the Liveness
826 // allocator TLS pointer.
827 Live = nullptr;
828 Live = Liveness::create(this, Mode);
829
823 getVMetadata()->init(VMK_Uses); 830 getVMetadata()->init(VMK_Uses);
824 Live->init(); 831 Live->init();
832
825 // Initialize with all nodes needing to be processed. 833 // Initialize with all nodes needing to be processed.
826 BitVector NeedToProcess(Nodes.size(), true); 834 BitVector NeedToProcess(Nodes.size(), true);
827 while (NeedToProcess.any()) { 835 while (NeedToProcess.any()) {
828 // Iterate in reverse topological order to speed up convergence. 836 // Iterate in reverse topological order to speed up convergence.
829 for (CfgNode *Node : reverse_range(Nodes)) { 837 for (CfgNode *Node : reverse_range(Nodes)) {
830 if (NeedToProcess[Node->getIndex()]) { 838 if (NeedToProcess[Node->getIndex()]) {
831 NeedToProcess[Node->getIndex()] = false; 839 NeedToProcess[Node->getIndex()] = false;
832 bool Changed = Node->liveness(getLiveness()); 840 bool Changed = Node->liveness(getLiveness());
833 if (Changed) { 841 if (Changed) {
834 // If the beginning-of-block liveness changed since the last 842 // If the beginning-of-block liveness changed since the last
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 } 1155 }
1148 } 1156 }
1149 // Print each basic block 1157 // Print each basic block
1150 for (CfgNode *Node : Nodes) 1158 for (CfgNode *Node : Nodes)
1151 Node->dump(this); 1159 Node->dump(this);
1152 if (isVerbose(IceV_Instructions)) 1160 if (isVerbose(IceV_Instructions))
1153 Str << "}\n"; 1161 Str << "}\n";
1154 } 1162 }
1155 1163
1156 } // end of namespace Ice 1164 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceBitVector.h ('k') | src/IceDefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698