@@ -1774,77 +1774,6 @@ static bool isSafeCheapLoadStore(const Instruction *I,
1774
1774
getLoadStoreAlignment (I) < Value::MaximumAlignment;
1775
1775
}
1776
1776
1777
- namespace {
1778
-
1779
- // LockstepReverseIterator - Iterates through instructions
1780
- // in a set of blocks in reverse order from the first non-terminator.
1781
- // For example (assume all blocks have size n):
1782
- // LockstepReverseIterator I([B1, B2, B3]);
1783
- // *I-- = [B1[n], B2[n], B3[n]];
1784
- // *I-- = [B1[n-1], B2[n-1], B3[n-1]];
1785
- // *I-- = [B1[n-2], B2[n-2], B3[n-2]];
1786
- // ...
1787
- class LockstepReverseIterator {
1788
- ArrayRef<BasicBlock *> Blocks;
1789
- SmallVector<Instruction *, 4 > Insts;
1790
- bool Fail;
1791
-
1792
- public:
1793
- LockstepReverseIterator (ArrayRef<BasicBlock *> Blocks) : Blocks(Blocks) {
1794
- reset ();
1795
- }
1796
-
1797
- void reset () {
1798
- Fail = false ;
1799
- Insts.clear ();
1800
- for (auto *BB : Blocks) {
1801
- Instruction *Inst = BB->getTerminator ();
1802
- for (Inst = Inst->getPrevNode (); Inst && isa<DbgInfoIntrinsic>(Inst);)
1803
- Inst = Inst->getPrevNode ();
1804
- if (!Inst) {
1805
- // Block wasn't big enough.
1806
- Fail = true ;
1807
- return ;
1808
- }
1809
- Insts.push_back (Inst);
1810
- }
1811
- }
1812
-
1813
- bool isValid () const { return !Fail; }
1814
-
1815
- void operator --() {
1816
- if (Fail)
1817
- return ;
1818
- for (auto *&Inst : Insts) {
1819
- for (Inst = Inst->getPrevNode (); Inst && isa<DbgInfoIntrinsic>(Inst);)
1820
- Inst = Inst->getPrevNode ();
1821
- // Already at beginning of block.
1822
- if (!Inst) {
1823
- Fail = true ;
1824
- return ;
1825
- }
1826
- }
1827
- }
1828
-
1829
- void operator ++() {
1830
- if (Fail)
1831
- return ;
1832
- for (auto *&Inst : Insts) {
1833
- for (Inst = Inst->getNextNode (); Inst && isa<DbgInfoIntrinsic>(Inst);)
1834
- Inst = Inst->getNextNode ();
1835
- // Already at end of block.
1836
- if (!Inst) {
1837
- Fail = true ;
1838
- return ;
1839
- }
1840
- }
1841
- }
1842
-
1843
- ArrayRef<Instruction *> operator *() const { return Insts; }
1844
- };
1845
-
1846
- } // end anonymous namespace
1847
-
1848
1777
// / Hoist any common code in the successor blocks up into the block. This
1849
1778
// / function guarantees that BB dominates all successors. If AllInstsEqOnly is
1850
1779
// / given, only perform hoisting in case all successors blocks contain matching
@@ -1896,7 +1825,7 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(Instruction *TI,
1896
1825
if (!AllSame)
1897
1826
return false ;
1898
1827
if (AllSame) {
1899
- LockstepReverseIterator LRI (Succs);
1828
+ LockstepReverseIterator< true > LRI (Succs);
1900
1829
while (LRI.isValid ()) {
1901
1830
Instruction *I0 = (*LRI)[0 ];
1902
1831
if (any_of (*LRI, [I0](Instruction *I) {
0 commit comments