[LDist][LVer] Explicitly pass the set of memchecks to LoopVersioning, NFC
authorAdam Nemet <anemet@apple.com>
Tue, 28 Jul 2015 05:01:53 +0000 (05:01 +0000)
committerAdam Nemet <anemet@apple.com>
Tue, 28 Jul 2015 05:01:53 +0000 (05:01 +0000)
Before the patch, the checks were generated internally in
addRuntimeCheck.  Now, we use the new overloaded version of
addRuntimeCheck that takes the ready-made set of checks as a parameter.

The checks are now generated by the client (LoopDistribution) with the
new RuntimePointerChecking::generateChecks API.

Also the new printChecks API is used to print out the checks for
debugging.

This is to continue the transition over to the new model whereby clients
will get the full set of checks from LAA, filter it and then pass it to
LoopVersioning and in turn to addRuntimeCheck.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243382 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/Utils/LoopVersioning.h
lib/Transforms/Scalar/LoopDistribute.cpp
lib/Transforms/Utils/LoopVersioning.cpp

index 009fba48c6a38fb2d0094935e3f60563e41024b2..077ae2a11bf587c93b536f02843883148233cb09 100644 (file)
@@ -31,7 +31,8 @@ class LoopInfo;
 /// already has a preheader.
 class LoopVersioning {
 public:
-  LoopVersioning(const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI,
+  LoopVersioning(SmallVector<RuntimePointerChecking::PointerCheck, 4> Checks,
+                 const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI,
                  DominatorTree *DT,
                  const SmallVector<int, 8> *PtrToPartition = nullptr);
 
@@ -90,6 +91,9 @@ private:
   /// in NonVersionedLoop.
   ValueToValueMapTy VMap;
 
+  /// \brief The set of checks that we are versioning for.
+  SmallVector<RuntimePointerChecking::PointerCheck, 4> Checks;
+
   /// \brief Analyses used.
   const LoopAccessInfo &LAI;
   LoopInfo *LI;
index 96ac582525dbcd103510f4a5c6e85d25eacadfc0..5ad4a454ce446767756661246629c9d3aeab5d36 100644 (file)
@@ -747,10 +747,12 @@ private:
     // If we need run-time checks to disambiguate pointers are run-time, version
     // the loop now.
     auto PtrToPartition = Partitions.computePartitionSetForPointers(LAI);
-    LoopVersioning LVer(LAI, L, LI, DT, &PtrToPartition);
-    if (LVer.needsRuntimeChecks()) {
+    auto Checks =
+        LAI.getRuntimePointerChecking()->generateChecks(&PtrToPartition);
+    if (!Checks.empty()) {
       DEBUG(dbgs() << "\nPointers:\n");
-      DEBUG(LAI.getRuntimePointerChecking()->print(dbgs(), 0, &PtrToPartition));
+      DEBUG(LAI.getRuntimePointerChecking()->printChecks(dbgs(), Checks));
+      LoopVersioning LVer(std::move(Checks), LAI, L, LI, DT);
       LVer.versionLoop(this);
       LVer.addPHINodes(DefsUsedOutside);
     }
index 832079d2cf63313003f059798d5d23f0c112d09d..b2182bd64092608a8ef633795c133e3a49a811cd 100644 (file)
 
 using namespace llvm;
 
-LoopVersioning::LoopVersioning(const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI,
-                               DominatorTree *DT,
-                               const SmallVector<int, 8> *PtrToPartition)
+LoopVersioning::LoopVersioning(
+    SmallVector<RuntimePointerChecking::PointerCheck, 4> Checks,
+    const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI, DominatorTree *DT,
+    const SmallVector<int, 8> *PtrToPartition)
     : VersionedLoop(L), NonVersionedLoop(nullptr),
-      PtrToPartition(PtrToPartition), LAI(LAI), LI(LI), DT(DT) {
+      PtrToPartition(PtrToPartition), Checks(Checks), LAI(LAI), LI(LI), DT(DT) {
   assert(L->getExitBlock() && "No single exit block");
   assert(L->getLoopPreheader() && "No preheader");
 }
@@ -41,7 +42,7 @@ void LoopVersioning::versionLoop(Pass *P) {
   // Add the memcheck in the original preheader (this is empty initially).
   BasicBlock *MemCheckBB = VersionedLoop->getLoopPreheader();
   std::tie(FirstCheckInst, MemRuntimeCheck) =
-      LAI.addRuntimeCheck(MemCheckBB->getTerminator(), PtrToPartition);
+      LAI.addRuntimeCheck(MemCheckBB->getTerminator(), Checks);
   assert(MemRuntimeCheck && "called even though needsAnyChecking = false");
 
   // Rename the block to make the IR more readable.