From a395eac8a8fbb95e7f4fe9055e769d02221130fe Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Wed, 12 Aug 2015 16:51:19 +0000 Subject: [PATCH] [LoopVer] Optionally allow using memchecks from LAA r243382 changed the behavior to always require a set of memchecks to be passed to LoopVer. This change restores the prior behavior as an alternative to the new behavior. This allows the checks to be implicitly taken from the LAA object. Patch by Ashutosh Nema! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244763 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/LoopAccessAnalysis.h | 2 +- include/llvm/Transforms/Utils/LoopVersioning.h | 7 +++++++ lib/Transforms/Utils/LoopVersioning.cpp | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/llvm/Analysis/LoopAccessAnalysis.h b/include/llvm/Analysis/LoopAccessAnalysis.h index 25da9827eea..c4a9dc42cc8 100644 --- a/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/include/llvm/Analysis/LoopAccessAnalysis.h @@ -384,7 +384,7 @@ public: bool UseDependencies); /// \brief Returns the checks that generateChecks created. - const SmallVectorImpl &getChecks() const { return Checks; } + const SmallVector &getChecks() const { return Checks; } /// \brief Decide if we need to add a check between two groups of pointers, /// according to needsChecking. diff --git a/include/llvm/Transforms/Utils/LoopVersioning.h b/include/llvm/Transforms/Utils/LoopVersioning.h index d4932fc5946..4779b7ede2b 100644 --- a/include/llvm/Transforms/Utils/LoopVersioning.h +++ b/include/llvm/Transforms/Utils/LoopVersioning.h @@ -31,10 +31,17 @@ class LoopInfo; /// already has a preheader. class LoopVersioning { public: + /// \brief Expects MemCheck, LoopAccessInfo, Loop, LoopInfo, DominatorTree + /// as input. It uses runtime check provided by user. LoopVersioning(SmallVector Checks, const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI, DominatorTree *DT); + /// \brief Expects LoopAccessInfo, Loop, LoopInfo, DominatorTree as input. + /// It uses default runtime check provided by LoopAccessInfo. + LoopVersioning(const LoopAccessInfo &LAInfo, Loop *L, LoopInfo *LI, + DominatorTree *DT); + /// \brief Performs the CFG manipulation part of versioning the loop including /// the DominatorTree and LoopInfo updates. /// diff --git a/lib/Transforms/Utils/LoopVersioning.cpp b/lib/Transforms/Utils/LoopVersioning.cpp index 4d2b1ee101f..ad2de241b40 100644 --- a/lib/Transforms/Utils/LoopVersioning.cpp +++ b/lib/Transforms/Utils/LoopVersioning.cpp @@ -31,6 +31,15 @@ LoopVersioning::LoopVersioning( assert(L->getLoopPreheader() && "No preheader"); } +LoopVersioning::LoopVersioning(const LoopAccessInfo &LAInfo, Loop *L, + LoopInfo *LI, DominatorTree *DT) + : VersionedLoop(L), NonVersionedLoop(nullptr), + Checks(LAInfo.getRuntimePointerChecking()->getChecks()), LAI(LAInfo), + LI(LI), DT(DT) { + assert(L->getExitBlock() && "No single exit block"); + assert(L->getLoopPreheader() && "No preheader"); +} + void LoopVersioning::versionLoop(Pass *P) { Instruction *FirstCheckInst; Instruction *MemRuntimeCheck; -- 2.34.1