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

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: Created 6 years, 7 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
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
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // (splice in "6Prefix") ^^^^^^^ 122 // (splice in "6Prefix") ^^^^^^^
123 snprintf(NewName, BufLen, "_ZN%u%s%s", PrefixLength, 123 snprintf(NewName, BufLen, "_ZN%u%s%s", PrefixLength,
124 getTestPrefix().c_str(), NameBase); 124 getTestPrefix().c_str(), NameBase);
125 // We ignore the snprintf return value (here and below). If we 125 // We ignore the snprintf return value (here and below). If we
126 // somehow miscalculated the output buffer length, the output will 126 // somehow miscalculated the output buffer length, the output will
127 // be truncated, but it will be truncated consistently for all 127 // be truncated, but it will be truncated consistently for all
128 // mangleName() calls on the same input string. 128 // mangleName() calls on the same input string.
129 return NewName; 129 return NewName;
130 } 130 }
131 131
132 ItemsParsed = sscanf(Name.c_str(), "_Z%u%s", &BaseLength, NameBase); 132 // Artificially limit BaseLength to 9 digits (less than 1 billion)
133 // because sscanf behavior is undefined on integer overflow.
JF 2014/05/25 22:50:50 Add an assert that has this comment.
Jim Stichnoth 2014/05/29 01:39:46 An assert isn't appropriate here. The idea is to
134 ItemsParsed = sscanf(Name.c_str(), "_Z%9u%s", &BaseLength, NameBase);
133 if (ItemsParsed == 2 && BaseLength <= strlen(NameBase)) { 135 if (ItemsParsed == 2 && BaseLength <= strlen(NameBase)) {
134 // Transform _Z3barxyz ==> _ZN6Prefix3barExyz 136 // Transform _Z3barxyz ==> _ZN6Prefix3barExyz
135 // ^^^^^^^^ ^ 137 // ^^^^^^^^ ^
136 // (splice in "N6Prefix", and insert "E" after "3bar") 138 // (splice in "N6Prefix", and insert "E" after "3bar")
137 // But an "I" after the identifier indicates a template argument 139 // But an "I" after the identifier indicates a template argument
138 // list terminated with "E"; insert the new "E" before/after the 140 // list terminated with "E"; insert the new "E" before/after the
139 // old "E". E.g.: 141 // old "E". E.g.:
140 // Transform _Z3barIabcExyz ==> _ZN6Prefix3barIabcEExyz 142 // Transform _Z3barIabcExyz ==> _ZN6Prefix3barIabcEExyz
141 // ^^^^^^^^ ^ 143 // ^^^^^^^^ ^
142 // (splice in "N6Prefix", and insert "E" after "3barIabcE") 144 // (splice in "N6Prefix", and insert "E" after "3barIabcE")
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 206
205 void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const { 207 void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const {
206 if (Ctx->isVerbose(IceV_Timing)) { 208 if (Ctx->isVerbose(IceV_Timing)) {
207 // Prefixing with '#' allows timing strings to be included 209 // Prefixing with '#' allows timing strings to be included
208 // without error in textual assembly output. 210 // without error in textual assembly output.
209 Ctx->getStrDump() << "# " << getElapsedUs() << " usec " << Tag << "\n"; 211 Ctx->getStrDump() << "# " << getElapsedUs() << " usec " << Tag << "\n";
210 } 212 }
211 } 213 }
212 214
213 } // end of namespace Ice 215 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698