| OLD | NEW |
| 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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 void Cfg::sortAndCombineAllocas(CfgVector<InstAlloca *> &Allocas, | 890 void Cfg::sortAndCombineAllocas(CfgVector<InstAlloca *> &Allocas, |
| 891 uint32_t CombinedAlignment, InstList &Insts, | 891 uint32_t CombinedAlignment, InstList &Insts, |
| 892 AllocaBaseVariableType BaseVariableType) { | 892 AllocaBaseVariableType BaseVariableType) { |
| 893 if (Allocas.empty()) | 893 if (Allocas.empty()) |
| 894 return; | 894 return; |
| 895 // Sort by decreasing alignment. | 895 // Sort by decreasing alignment. |
| 896 std::sort(Allocas.begin(), Allocas.end(), [](InstAlloca *A1, InstAlloca *A2) { | 896 std::sort(Allocas.begin(), Allocas.end(), [](InstAlloca *A1, InstAlloca *A2) { |
| 897 uint32_t Align1 = A1->getAlignInBytes(); | 897 uint32_t Align1 = A1->getAlignInBytes(); |
| 898 uint32_t Align2 = A2->getAlignInBytes(); | 898 uint32_t Align2 = A2->getAlignInBytes(); |
| 899 if (Align1 == Align2) | 899 if (Align1 == Align2) |
| 900 return A1->getNumber() > A2->getNumber(); | 900 return A1->getNumber() < A2->getNumber(); |
| 901 else | 901 else |
| 902 return Align1 > Align2; | 902 return Align1 > Align2; |
| 903 }); | 903 }); |
| 904 // Process the allocas in order of decreasing stack alignment. This allows | 904 // Process the allocas in order of decreasing stack alignment. This allows |
| 905 // us to pack less-aligned pieces after more-aligned ones, resulting in less | 905 // us to pack less-aligned pieces after more-aligned ones, resulting in less |
| 906 // stack growth. It also allows there to be at most one stack alignment "and" | 906 // stack growth. It also allows there to be at most one stack alignment "and" |
| 907 // instruction for a whole list of allocas. | 907 // instruction for a whole list of allocas. |
| 908 uint32_t CurrentOffset = 0; | 908 uint32_t CurrentOffset = 0; |
| 909 CfgVector<int32_t> Offsets; | 909 CfgVector<int32_t> Offsets; |
| 910 for (Inst *Instr : Allocas) { | 910 for (Inst *Instr : Allocas) { |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 } | 1861 } |
| 1862 } | 1862 } |
| 1863 // Print each basic block | 1863 // Print each basic block |
| 1864 for (CfgNode *Node : Nodes) | 1864 for (CfgNode *Node : Nodes) |
| 1865 Node->dump(this); | 1865 Node->dump(this); |
| 1866 if (isVerbose(IceV_Instructions)) | 1866 if (isVerbose(IceV_Instructions)) |
| 1867 Str << "}\n"; | 1867 Str << "}\n"; |
| 1868 } | 1868 } |
| 1869 | 1869 |
| 1870 } // end of namespace Ice | 1870 } // end of namespace Ice |
| OLD | NEW |