| 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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 void Cfg::sortAndCombineAllocas(CfgVector<InstAlloca *> &Allocas, | 796 void Cfg::sortAndCombineAllocas(CfgVector<InstAlloca *> &Allocas, |
| 797 uint32_t CombinedAlignment, InstList &Insts, | 797 uint32_t CombinedAlignment, InstList &Insts, |
| 798 AllocaBaseVariableType BaseVariableType) { | 798 AllocaBaseVariableType BaseVariableType) { |
| 799 if (Allocas.empty()) | 799 if (Allocas.empty()) |
| 800 return; | 800 return; |
| 801 // Sort by decreasing alignment. | 801 // Sort by decreasing alignment. |
| 802 std::sort(Allocas.begin(), Allocas.end(), [](InstAlloca *A1, InstAlloca *A2) { | 802 std::sort(Allocas.begin(), Allocas.end(), [](InstAlloca *A1, InstAlloca *A2) { |
| 803 uint32_t Align1 = A1->getAlignInBytes(); | 803 uint32_t Align1 = A1->getAlignInBytes(); |
| 804 uint32_t Align2 = A2->getAlignInBytes(); | 804 uint32_t Align2 = A2->getAlignInBytes(); |
| 805 if (Align1 == Align2) | 805 if (Align1 == Align2) |
| 806 return A1->getNumber() > A2->getNumber(); | 806 return A1->getNumber() < A2->getNumber(); |
| 807 else | 807 else |
| 808 return Align1 > Align2; | 808 return Align1 > Align2; |
| 809 }); | 809 }); |
| 810 // Process the allocas in order of decreasing stack alignment. This allows | 810 // Process the allocas in order of decreasing stack alignment. This allows |
| 811 // us to pack less-aligned pieces after more-aligned ones, resulting in less | 811 // us to pack less-aligned pieces after more-aligned ones, resulting in less |
| 812 // stack growth. It also allows there to be at most one stack alignment "and" | 812 // stack growth. It also allows there to be at most one stack alignment "and" |
| 813 // instruction for a whole list of allocas. | 813 // instruction for a whole list of allocas. |
| 814 uint32_t CurrentOffset = 0; | 814 uint32_t CurrentOffset = 0; |
| 815 CfgVector<int32_t> Offsets; | 815 CfgVector<int32_t> Offsets; |
| 816 for (Inst *Instr : Allocas) { | 816 for (Inst *Instr : Allocas) { |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1767 } | 1767 } |
| 1768 } | 1768 } |
| 1769 // Print each basic block | 1769 // Print each basic block |
| 1770 for (CfgNode *Node : Nodes) | 1770 for (CfgNode *Node : Nodes) |
| 1771 Node->dump(this); | 1771 Node->dump(this); |
| 1772 if (isVerbose(IceV_Instructions)) | 1772 if (isVerbose(IceV_Instructions)) |
| 1773 Str << "}\n"; | 1773 Str << "}\n"; |
| 1774 } | 1774 } |
| 1775 | 1775 |
| 1776 } // end of namespace Ice | 1776 } // end of namespace Ice |
| OLD | NEW |