[llvm] r243382 - [LDist][LVer] Explicitly pass the set of memchecks to LoopVersioning, NFC

Adam Nemet anemet at apple.com
Mon Aug 3 22:50:06 PDT 2015


> On Aug 3, 2015, at 10:32 PM, Nema, Ashutosh <Ashutosh.Nema at amd.com> wrote:
> 
>> 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.
> 
> Hi Adam,
> 
> With this change, we always needs to pass runtime checks to LoopVersioning.
> In some cases we expect loopVersioning itself to create checks(This is how it was implemented earlier).
> We should provide that flexibility, but with this change I'm not sure how to get that behavior.

Hi Ashutosh,

Sure, I can restore that variant.  Do you mean just to get the checks from LAA, right?

Adam


> 
> Regards,
> Ashutosh
> 
> -----Original Message-----
> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Adam Nemet
> Sent: Tuesday, July 28, 2015 10:32 AM
> To: llvm-commits at cs.uiuc.edu
> Subject: [llvm] r243382 - [LDist][LVer] Explicitly pass the set of memchecks to LoopVersioning, NFC
> 
> Author: anemet
> Date: Tue Jul 28 00:01:53 2015
> New Revision: 243382
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=243382&view=rev
> Log:
> [LDist][LVer] Explicitly pass the set of memchecks to LoopVersioning, NFC
> 
> 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.
> 
> Modified:
>    llvm/trunk/include/llvm/Transforms/Utils/LoopVersioning.h
>    llvm/trunk/lib/Transforms/Scalar/LoopDistribute.cpp
>    llvm/trunk/lib/Transforms/Utils/LoopVersioning.cpp
> 
> Modified: llvm/trunk/include/llvm/Transforms/Utils/LoopVersioning.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/LoopVersioning.h?rev=243382&r1=243381&r2=243382&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Transforms/Utils/LoopVersioning.h (original)
> +++ llvm/trunk/include/llvm/Transforms/Utils/LoopVersioning.h Tue Jul 28 00:01:53 2015
> @@ -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;
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/LoopDistribute.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopDistribute.cpp?rev=243382&r1=243381&r2=243382&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/LoopDistribute.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/LoopDistribute.cpp Tue Jul 28 00:01:53 2015
> @@ -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);
>     }
> 
> Modified: llvm/trunk/lib/Transforms/Utils/LoopVersioning.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopVersioning.cpp?rev=243382&r1=243381&r2=243382&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/LoopVersioning.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/LoopVersioning.cpp Tue Jul 28 00:01:53 2015
> @@ -22,11 +22,12 @@
> 
> 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.
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list