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

Side by Side Diff: src/IceGlobalContext.cpp

Issue 300563003: Subzero: Initial O2 lowering (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Jan's third-round comments Created 6 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 | « src/IceDefs.h ('k') | src/IceInst.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/IceGlobalContext.cpp - Global context defs ---*- C++ -*-===// 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs ---*- 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 // This file defines aspects of the compilation that persist across 10 // This file defines aspects of the compilation that persist across
11 // multiple functions. 11 // multiple functions.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include <ctype.h> // isdigit()
16
15 #include "IceDefs.h" 17 #include "IceDefs.h"
16 #include "IceTypes.h" 18 #include "IceTypes.h"
17 #include "IceCfg.h" 19 #include "IceCfg.h"
18 #include "IceGlobalContext.h" 20 #include "IceGlobalContext.h"
19 #include "IceOperand.h" 21 #include "IceOperand.h"
20 #include "IceTargetLowering.h" 22 #include "IceTargetLowering.h"
21 23
22 namespace Ice { 24 namespace Ice {
23 25
24 // TypePool maps constants of type KeyType (e.g. float) to pointers to 26 // TypePool maps constants of type KeyType (e.g. float) to pointers to
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // (splice in "6Prefix") ^^^^^^^ 124 // (splice in "6Prefix") ^^^^^^^
123 snprintf(NewName, BufLen, "_ZN%u%s%s", PrefixLength, 125 snprintf(NewName, BufLen, "_ZN%u%s%s", PrefixLength,
124 getTestPrefix().c_str(), NameBase); 126 getTestPrefix().c_str(), NameBase);
125 // We ignore the snprintf return value (here and below). If we 127 // We ignore the snprintf return value (here and below). If we
126 // somehow miscalculated the output buffer length, the output will 128 // somehow miscalculated the output buffer length, the output will
127 // be truncated, but it will be truncated consistently for all 129 // be truncated, but it will be truncated consistently for all
128 // mangleName() calls on the same input string. 130 // mangleName() calls on the same input string.
129 return NewName; 131 return NewName;
130 } 132 }
131 133
132 ItemsParsed = sscanf(Name.c_str(), "_Z%u%s", &BaseLength, NameBase); 134 // Artificially limit BaseLength to 9 digits (less than 1 billion)
133 if (ItemsParsed == 2 && BaseLength <= strlen(NameBase)) { 135 // because sscanf behavior is undefined on integer overflow. If
136 // there are more than 9 digits (which we test by looking at the
137 // beginning of NameBase), then we consider this a failure to parse
138 // a namespace mangling, and fall back to the simple prefixing.
139 ItemsParsed = sscanf(Name.c_str(), "_Z%9u%s", &BaseLength, NameBase);
140 if (ItemsParsed == 2 && BaseLength <= strlen(NameBase) &&
141 !isdigit(NameBase[0])) {
134 // Transform _Z3barxyz ==> _ZN6Prefix3barExyz 142 // Transform _Z3barxyz ==> _ZN6Prefix3barExyz
135 // ^^^^^^^^ ^ 143 // ^^^^^^^^ ^
136 // (splice in "N6Prefix", and insert "E" after "3bar") 144 // (splice in "N6Prefix", and insert "E" after "3bar")
137 // But an "I" after the identifier indicates a template argument 145 // But an "I" after the identifier indicates a template argument
138 // list terminated with "E"; insert the new "E" before/after the 146 // list terminated with "E"; insert the new "E" before/after the
139 // old "E". E.g.: 147 // old "E". E.g.:
140 // Transform _Z3barIabcExyz ==> _ZN6Prefix3barIabcEExyz 148 // Transform _Z3barIabcExyz ==> _ZN6Prefix3barIabcEExyz
141 // ^^^^^^^^ ^ 149 // ^^^^^^^^ ^
142 // (splice in "N6Prefix", and insert "E" after "3barIabcE") 150 // (splice in "N6Prefix", and insert "E" after "3barIabcE")
143 char OrigName[Name.length()]; 151 char OrigName[Name.length()];
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 212
205 void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const { 213 void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const {
206 if (Ctx->isVerbose(IceV_Timing)) { 214 if (Ctx->isVerbose(IceV_Timing)) {
207 // Prefixing with '#' allows timing strings to be included 215 // Prefixing with '#' allows timing strings to be included
208 // without error in textual assembly output. 216 // without error in textual assembly output.
209 Ctx->getStrDump() << "# " << getElapsedUs() << " usec " << Tag << "\n"; 217 Ctx->getStrDump() << "# " << getElapsedUs() << " usec " << Tag << "\n";
210 } 218 }
211 } 219 }
212 220
213 } // end of namespace Ice 221 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceDefs.h ('k') | src/IceInst.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698