[llvm] r312575 - [GVNHoist] Move duplicated code to a helper function. NFCI.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 5 13:49:41 PDT 2017
Author: davide
Date: Tue Sep 5 13:49:41 2017
New Revision: 312575
URL: http://llvm.org/viewvc/llvm-project?rev=312575&view=rev
Log:
[GVNHoist] Move duplicated code to a helper function. NFCI.
Modified:
llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp?rev=312575&r1=312574&r2=312575&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVNHoist.cpp Tue Sep 5 13:49:41 2017
@@ -387,6 +387,25 @@ private:
return false;
}
+ bool hasEHhelper(const BasicBlock *BB, const BasicBlock *SrcBB,
+ int &NBBsOnAllPaths) {
+ // Stop walk once the limit is reached.
+ if (NBBsOnAllPaths == 0)
+ return true;
+
+ // Impossible to hoist with exceptions on the path.
+ if (hasEH(BB))
+ return true;
+
+ // No such instruction after HoistBarrier in a basic block was
+ // selected for hoisting so instructions selected within basic block with
+ // a hoist barrier can be hoisted.
+ if ((BB != SrcBB) && HoistBarrier.count(BB))
+ return true;
+
+ return false;
+ }
+
// Return true when there are exception handling or loads of memory Def
// between Def and NewPt. This function is only called for stores: Def is
// the MemoryDef of the store to be hoisted.
@@ -414,18 +433,7 @@ private:
continue;
}
- // Stop walk once the limit is reached.
- if (NBBsOnAllPaths == 0)
- return true;
-
- // Impossible to hoist with exceptions on the path.
- if (hasEH(BB))
- return true;
-
- // No such instruction after HoistBarrier in a basic block was
- // selected for hoisting so instructions selected within basic block with
- // a hoist barrier can be hoisted.
- if ((BB != OldBB) && HoistBarrier.count(BB))
+ if (hasEHhelper(BB, OldBB, NBBsOnAllPaths))
return true;
// Check that we do not move a store past loads.
@@ -463,18 +471,7 @@ private:
continue;
}
- // Stop walk once the limit is reached.
- if (NBBsOnAllPaths == 0)
- return true;
-
- // Impossible to hoist with exceptions on the path.
- if (hasEH(BB))
- return true;
-
- // No such instruction after HoistBarrier in a basic block was
- // selected for hoisting so instructions selected within basic block with
- // a hoist barrier can be hoisted.
- if ((BB != SrcBB) && HoistBarrier.count(BB))
+ if (hasEHhelper(BB, SrcBB, NBBsOnAllPaths))
return true;
// -1 is unlimited number of blocks on all paths.
More information about the llvm-commits
mailing list