From: Dehao Chen Date: Thu, 1 Sep 2016 23:31:25 +0000 (+0000) Subject: Refactor LICM to expose canSinkOrHoistInst to LoopSink pass. X-Git-Tag: llvmorg-4.0.0-rc1~10827 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e81d50b3b9fce8abb9dff7526ec92e15666a692f;p=platform%2Fupstream%2Fllvm.git Refactor LICM to expose canSinkOrHoistInst to LoopSink pass. Summary: LoopSink pass shares the same canSinkOrHoistInst functionality with LICM pass. This patch exposes this function in preparation of https://reviews.llvm.org/D22778 Reviewers: chandlerc, davidxl, danielcdh Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24171 llvm-svn: 280429 --- diff --git a/llvm/include/llvm/Transforms/Utils/LoopUtils.h b/llvm/include/llvm/Transforms/Utils/LoopUtils.h index 24405445..50dc752 100644 --- a/llvm/include/llvm/Transforms/Utils/LoopUtils.h +++ b/llvm/include/llvm/Transforms/Utils/LoopUtils.h @@ -21,12 +21,14 @@ #include "llvm/IR/IRBuilder.h" namespace llvm { +class AAResults; class AliasSet; class AliasSetTracker; class AssumptionCache; class BasicBlock; class DataLayout; class DominatorTree; +class Instruction; class Loop; class LoopInfo; class Pass; @@ -467,6 +469,12 @@ void addStringMetadataToLoop(Loop *TheLoop, const char *MDString, /// All loop passes should call this as part of implementing their \c /// getAnalysisUsage. void getLoopAnalysisUsage(AnalysisUsage &AU); -} +/// canSinkOrHoistInst - Return true if the hoister and sinker can handle this +/// instruction. If SafetyInfo is not nullptr, check if the instruction can +/// execute speculatively. +bool canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, + Loop *CurLoop, AliasSetTracker *CurAST, + LoopSafetyInfo *SafetyInfo); +} #endif diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index 99d7e2e..c8af309 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -100,10 +100,6 @@ static Instruction * CloneInstructionInExitBlock(Instruction &I, BasicBlock &ExitBlock, PHINode &PN, const LoopInfo *LI, const LoopSafetyInfo *SafetyInfo); -static bool canSinkOrHoistInst(Instruction &I, AliasAnalysis *AA, - DominatorTree *DT, - Loop *CurLoop, AliasSetTracker *CurAST, - LoopSafetyInfo *SafetyInfo); namespace { struct LoopInvariantCodeMotion { @@ -439,9 +435,9 @@ void llvm::computeLoopSafetyInfo(LoopSafetyInfo *SafetyInfo, Loop *CurLoop) { /// canSinkOrHoistInst - Return true if the hoister and sinker can handle this /// instruction. /// -bool canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, - Loop *CurLoop, AliasSetTracker *CurAST, - LoopSafetyInfo *SafetyInfo) { +bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, + Loop *CurLoop, AliasSetTracker *CurAST, + LoopSafetyInfo *SafetyInfo) { if (!isa(I) && !isa(I) && !isa(I) && !isa(I) && !isa(I) && !isa(I) && !isa(I) &&