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

Side by Side Diff: src/IceCfg.cpp

Issue 1181013016: Subzero. Fixes memory leaks. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: clang-format: for f in $(git diff --name-only HEAD~7); do if [[ ${f} == *h || ${f} == *cpp ]]; then… Created 5 years, 6 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 | « no previous file | src/IceConverter.cpp » ('j') | src/IceDefs.h » ('J')
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 // This file implements the Cfg class, including constant pool 10 // This file implements the Cfg class, including constant pool
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 // Returns whether the stack frame layout has been computed yet. This 75 // Returns whether the stack frame layout has been computed yet. This
76 // is used for dumping the stack frame location of Variables. 76 // is used for dumping the stack frame location of Variables.
77 bool Cfg::hasComputedFrame() const { return getTarget()->hasComputedFrame(); } 77 bool Cfg::hasComputedFrame() const { return getTarget()->hasComputedFrame(); }
78 78
79 namespace { 79 namespace {
80 constexpr char BlockNameGlobalPrefix[] = ".L$profiler$block_name$"; 80 constexpr char BlockNameGlobalPrefix[] = ".L$profiler$block_name$";
81 constexpr char BlockStatsGlobalPrefix[] = ".L$profiler$block_info$"; 81 constexpr char BlockStatsGlobalPrefix[] = ".L$profiler$block_info$";
82 82
83 VariableDeclaration *nodeNameDeclaration(const IceString &NodeAsmName) { 83 VariableDeclaration *nodeNameDeclaration(GlobalContext *Ctx,
84 VariableDeclaration *Var = VariableDeclaration::create(); 84 const IceString &NodeAsmName) {
85 VariableDeclaration *Var = VariableDeclaration::create(Ctx);
85 Var->setName(BlockNameGlobalPrefix + NodeAsmName); 86 Var->setName(BlockNameGlobalPrefix + NodeAsmName);
86 Var->setIsConstant(true); 87 Var->setIsConstant(true);
87 Var->addInitializer(new VariableDeclaration::DataInitializer( 88 Var->addInitializer(VariableDeclaration::DataInitializer::create(
88 NodeAsmName.data(), NodeAsmName.size() + 1)); 89 NodeAsmName.data(), NodeAsmName.size() + 1));
89 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64); 90 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64);
90 Var->setAlignment(Int64ByteSize); // Wasteful, 32-bit could use 4 bytes. 91 Var->setAlignment(Int64ByteSize); // Wasteful, 32-bit could use 4 bytes.
91 return Var; 92 return Var;
92 } 93 }
93 94
94 VariableDeclaration * 95 VariableDeclaration *
95 blockProfilingInfoDeclaration(const IceString &NodeAsmName, 96 blockProfilingInfoDeclaration(GlobalContext *Ctx, const IceString &NodeAsmName,
96 VariableDeclaration *NodeNameDeclaration) { 97 VariableDeclaration *NodeNameDeclaration) {
97 VariableDeclaration *Var = VariableDeclaration::create(); 98 VariableDeclaration *Var = VariableDeclaration::create(Ctx);
98 Var->setName(BlockStatsGlobalPrefix + NodeAsmName); 99 Var->setName(BlockStatsGlobalPrefix + NodeAsmName);
99 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64); 100 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64);
100 Var->addInitializer(new VariableDeclaration::ZeroInitializer(Int64ByteSize)); 101 Var->addInitializer(
102 VariableDeclaration::ZeroInitializer::create(Int64ByteSize));
101 103
102 const RelocOffsetT NodeNameDeclarationOffset = 0; 104 const RelocOffsetT NodeNameDeclarationOffset = 0;
103 Var->addInitializer(new VariableDeclaration::RelocInitializer( 105 Var->addInitializer(VariableDeclaration::RelocInitializer::create(
104 NodeNameDeclaration, NodeNameDeclarationOffset)); 106 NodeNameDeclaration, NodeNameDeclarationOffset));
105 Var->setAlignment(Int64ByteSize); 107 Var->setAlignment(Int64ByteSize);
106 return Var; 108 return Var;
107 } 109 }
108
109 } // end of anonymous namespace 110 } // end of anonymous namespace
110 111
111 void Cfg::profileBlocks() { 112 void Cfg::profileBlocks() {
112 if (GlobalInits == nullptr) 113 if (GlobalInits == nullptr)
113 GlobalInits.reset(new VariableDeclarationList()); 114 GlobalInits.reset(new VariableDeclarationList());
114 115
115 for (CfgNode *Node : Nodes) { 116 for (CfgNode *Node : Nodes) {
116 IceString NodeAsmName = Node->getAsmName(); 117 IceString NodeAsmName = Node->getAsmName();
117 GlobalInits->push_back(nodeNameDeclaration(NodeAsmName)); 118 GlobalInits->push_back(nodeNameDeclaration(Ctx, NodeAsmName));
118 GlobalInits->push_back( 119 GlobalInits->push_back(
119 blockProfilingInfoDeclaration(NodeAsmName, GlobalInits->back())); 120 blockProfilingInfoDeclaration(Ctx, NodeAsmName, GlobalInits->back()));
120 Node->profileExecutionCount(GlobalInits->back()); 121 Node->profileExecutionCount(GlobalInits->back());
121 } 122 }
122 } 123 }
123 124
124 bool Cfg::isProfileGlobal(const VariableDeclaration &Var) { 125 bool Cfg::isProfileGlobal(const VariableDeclaration &Var) {
125 return Var.getName().find(BlockStatsGlobalPrefix) == 0; 126 return Var.getName().find(BlockStatsGlobalPrefix) == 0;
126 } 127 }
127 128
128 void Cfg::addCallToProfileSummary() { 129 void Cfg::addCallToProfileSummary() {
129 // The call(s) to __Sz_profile_summary are added by the profiler in functions 130 // The call(s) to __Sz_profile_summary are added by the profiler in functions
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 } 620 }
620 } 621 }
621 // Print each basic block 622 // Print each basic block
622 for (CfgNode *Node : Nodes) 623 for (CfgNode *Node : Nodes)
623 Node->dump(this); 624 Node->dump(this);
624 if (isVerbose(IceV_Instructions)) 625 if (isVerbose(IceV_Instructions))
625 Str << "}\n"; 626 Str << "}\n";
626 } 627 }
627 628
628 } // end of namespace Ice 629 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | src/IceConverter.cpp » ('j') | src/IceDefs.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698