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

Side by Side Diff: src/IceRegAlloc.cpp

Issue 650613003: Subzero: Speed up VariablesMetadata initialization. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Split Definitions[] into first plus the rest Created 6 years, 2 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/IceOperand.cpp ('k') | src/IceTargetLoweringX8632.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/IceRegAlloc.cpp - Linear-scan implementation -----------===// 1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan 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 LinearScan class, which performs the 10 // This file implements the LinearScan class, which performs the
(...skipping 14 matching lines...) Expand all
25 25
26 // Returns true if Var has any definitions within Item's live range. 26 // Returns true if Var has any definitions within Item's live range.
27 // TODO(stichnot): Consider trimming the Definitions list similar to 27 // TODO(stichnot): Consider trimming the Definitions list similar to
28 // how the live ranges are trimmed, since all the overlapsDefs() tests 28 // how the live ranges are trimmed, since all the overlapsDefs() tests
29 // are whether some variable's definitions overlap Cur, and trimming 29 // are whether some variable's definitions overlap Cur, and trimming
30 // is with respect Cur.start. Initial tests show no measurable 30 // is with respect Cur.start. Initial tests show no measurable
31 // performance difference, so we'll keep the code simple for now. 31 // performance difference, so we'll keep the code simple for now.
32 bool overlapsDefs(const Cfg *Func, const Variable *Item, const Variable *Var) { 32 bool overlapsDefs(const Cfg *Func, const Variable *Item, const Variable *Var) {
33 const bool UseTrimmed = true; 33 const bool UseTrimmed = true;
34 VariablesMetadata *VMetadata = Func->getVMetadata(); 34 VariablesMetadata *VMetadata = Func->getVMetadata();
35 const InstDefList &Defs = VMetadata->getDefinitions(Var); 35 if (const Inst *FirstDef = VMetadata->getFirstDefinition(Var))
36 if (Item->getLiveRange().overlapsInst(FirstDef->getNumber(), UseTrimmed))
37 return true;
38 const InstDefList &Defs = VMetadata->getLatterDefinitions(Var);
36 for (size_t i = 0; i < Defs.size(); ++i) { 39 for (size_t i = 0; i < Defs.size(); ++i) {
37 if (Item->getLiveRange().overlapsInst(Defs[i]->getNumber(), UseTrimmed)) 40 if (Item->getLiveRange().overlapsInst(Defs[i]->getNumber(), UseTrimmed))
38 return true; 41 return true;
39 } 42 }
40 return false; 43 return false;
41 } 44 }
42 45
43 void dumpDisableOverlap(const Cfg *Func, const Variable *Var, 46 void dumpDisableOverlap(const Cfg *Func, const Variable *Var,
44 const char *Reason) { 47 const char *Reason) {
45 if (Func->getContext()->isVerbose(IceV_LinearScan)) { 48 if (Func->getContext()->isVerbose(IceV_LinearScan)) {
46 VariablesMetadata *VMetadata = Func->getVMetadata(); 49 VariablesMetadata *VMetadata = Func->getVMetadata();
47 Ostream &Str = Func->getContext()->getStrDump(); 50 Ostream &Str = Func->getContext()->getStrDump();
48 Str << "Disabling Overlap due to " << Reason << " " << *Var 51 Str << "Disabling Overlap due to " << Reason << " " << *Var
49 << " LIVE=" << Var->getLiveRange() << " Defs="; 52 << " LIVE=" << Var->getLiveRange() << " Defs=";
50 const InstDefList &Defs = VMetadata->getDefinitions(Var); 53 if (const Inst *FirstDef = VMetadata->getFirstDefinition(Var))
54 Str << FirstDef->getNumber();
55 const InstDefList &Defs = VMetadata->getLatterDefinitions(Var);
51 for (size_t i = 0; i < Defs.size(); ++i) { 56 for (size_t i = 0; i < Defs.size(); ++i) {
jvoung (off chromium) 2014/10/15 22:10:37 Might be able to use a range-based for-loop now th
Jim Stichnoth 2014/10/15 22:12:44 Yeah, though I was thinking of making one big pass
52 if (i > 0) 57 Str << "," << Defs[i]->getNumber();
53 Str << ",";
54 Str << Defs[i]->getNumber();
55 } 58 }
56 Str << "\n"; 59 Str << "\n";
57 } 60 }
58 } 61 }
59 62
60 void dumpLiveRange(const Variable *Var, const Cfg *Func) { 63 void dumpLiveRange(const Variable *Var, const Cfg *Func) {
61 Ostream &Str = Func->getContext()->getStrDump(); 64 Ostream &Str = Func->getContext()->getStrDump();
62 const static size_t BufLen = 30; 65 const static size_t BufLen = 30;
63 char buf[BufLen]; 66 char buf[BufLen];
64 snprintf(buf, BufLen, "%2d", Var->getRegNumTmp()); 67 snprintf(buf, BufLen, "%2d", Var->getRegNumTmp());
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 Str << "\n"; 572 Str << "\n";
570 } 573 }
571 Str << "++++++ Inactive:\n"; 574 Str << "++++++ Inactive:\n";
572 for (const Variable *Item : Inactive) { 575 for (const Variable *Item : Inactive) {
573 dumpLiveRange(Item, Func); 576 dumpLiveRange(Item, Func);
574 Str << "\n"; 577 Str << "\n";
575 } 578 }
576 } 579 }
577 580
578 } // end of namespace Ice 581 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceOperand.cpp ('k') | src/IceTargetLoweringX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698