LLVM
8.0.1
|
#include "llvm/Pass.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Statepoint.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "safepoint-placement" |
Functions | |
STATISTIC (NumEntrySafepoints, "Number of entry safepoints inserted") | |
STATISTIC (NumBackedgeSafepoints, "Number of backedge safepoints inserted") | |
STATISTIC (CallInLoop, "Number of loops without safepoints due to calls in loop") | |
STATISTIC (FiniteExecution, "Number of loops without safepoints finite execution") | |
static void | InsertSafepointPoll (Instruction *InsertBefore, std::vector< CallSite > &ParsePointsNeeded, const TargetLibraryInfo &TLI) |
static bool | needsStatepoint (const CallSite &CS, const TargetLibraryInfo &TLI) |
static bool | containsUnconditionalCallSafepoint (Loop *L, BasicBlock *Header, BasicBlock *Pred, DominatorTree &DT, const TargetLibraryInfo &TLI) |
Returns true if this loop is known to contain a call safepoint which must unconditionally execute on any iteration of the loop which returns to the loop header via an edge from Pred. More... | |
static bool | mustBeFiniteCountedLoop (Loop *L, ScalarEvolution *SE, BasicBlock *Pred) |
Returns true if this loop is known to terminate in a finite number of iterations. More... | |
static void | scanOneBB (Instruction *Start, Instruction *End, std::vector< CallInst *> &Calls, DenseSet< BasicBlock *> &Seen, std::vector< BasicBlock *> &Worklist) |
static void | scanInlinedCode (Instruction *Start, Instruction *End, std::vector< CallInst *> &Calls, DenseSet< BasicBlock *> &Seen) |
static bool | doesNotRequireEntrySafepointBefore (const CallSite &CS) |
Returns true if an entry safepoint is not required before this callsite in the caller function. More... | |
static Instruction * | findLocationForEntrySafepoint (Function &F, DominatorTree &DT) |
static bool | isGCSafepointPoll (Function &F) |
static bool | shouldRewriteFunction (Function &F) |
Returns true if this function should be rewritten to include safepoint polls and parseable call sites. More... | |
static bool | enableEntrySafepoints (Function &F) |
static bool | enableBackedgeSafepoints (Function &F) |
static bool | enableCallSafepoints (Function &F) |
INITIALIZE_PASS_BEGIN (PlaceBackedgeSafepointsImpl, "place-backedge-safepoints-impl", "Place Backedge Safepoints", false, false) INITIALIZE_PASS_END(PlaceBackedgeSafepointsImpl | |
place backedge safepoints Place Backedge false | INITIALIZE_PASS_BEGIN (PlaceSafepoints, "place-safepoints", "Place Safepoints", false, false) INITIALIZE_PASS_END(PlaceSafepoints |
Variables | |
static cl::opt< bool > | AllBackedges ("spp-all-backedges", cl::Hidden, cl::init(false)) |
static cl::opt< int > | CountedLoopTripWidth ("spp-counted-loop-trip-width", cl::Hidden, cl::init(32)) |
How narrow does the trip count of a loop have to be to have to be considered "counted"? Counted loops do not get safepoints at backedges. More... | |
static cl::opt< bool > | SplitBackedge ("spp-split-backedge", cl::Hidden, cl::init(false)) |
static cl::opt< bool > | NoEntry ("spp-no-entry", cl::Hidden, cl::init(false)) |
static cl::opt< bool > | NoCall ("spp-no-call", cl::Hidden, cl::init(false)) |
static cl::opt< bool > | NoBackedge ("spp-no-backedge", cl::Hidden, cl::init(false)) |
static const char *const | GCSafepointPollName = "gc.safepoint_poll" |
place backedge safepoints | impl |
place backedge safepoints Place Backedge | Safepoints |
place backedge safepoints Place Backedge | false |
place backedge safepoints Place Backedge false place | safepoints |
#define DEBUG_TYPE "safepoint-placement" |
Definition at line 70 of file PlaceSafepoints.cpp.
|
static |
Returns true if this loop is known to contain a call safepoint which must unconditionally execute on any iteration of the loop which returns to the loop header via an edge from Pred.
Returns a conservative correct answer; i.e. false is always valid.
Definition at line 201 of file PlaceSafepoints.cpp.
References assert(), llvm::DominatorTree::dominates(), llvm::DomTreeNodeBase< NodeT >::getBlock(), llvm::DomTreeNodeBase< NodeT >::getIDom(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), I, and needsStatepoint().
Returns true if an entry safepoint is not required before this callsite in the caller function.
Definition at line 363 of file PlaceSafepoints.cpp.
References llvm::Intrinsic::experimental_gc_statepoint, llvm::Intrinsic::experimental_patchpoint_i64, llvm::Intrinsic::experimental_patchpoint_void, and llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction().
Referenced by findLocationForEntrySafepoint().
Definition at line 464 of file PlaceSafepoints.cpp.
References NoBackedge.
Referenced by enableCallSafepoints().
Definition at line 465 of file PlaceSafepoints.cpp.
References assert(), llvm::DominatorTree::dominates(), llvm::SetVector< T, Vector, Set >::empty(), llvm::Function::empty(), enableBackedgeSafepoints(), enableEntrySafepoints(), F(), findLocationForEntrySafepoint(), llvm::Value::getName(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::BasicBlock::getTerminator(), llvm::SetVector< T, Vector, Set >::insert(), InsertSafepointPoll(), llvm::GlobalValue::isDeclaration(), isGCSafepointPoll(), Modified, NoCall, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::DominatorTreeBase< NodeT, IsPostDom >::recalculate(), llvm::removeUnreachableBlocks(), runOnFunction(), shouldRewriteFunction(), llvm::sort(), SplitBackedge, and llvm::SplitEdge().
Definition at line 463 of file PlaceSafepoints.cpp.
References NoEntry.
Referenced by enableCallSafepoints().
|
static |
Definition at line 387 of file PlaceSafepoints.cpp.
References assert(), doesNotRequireEntrySafepointBefore(), llvm::BasicBlock::front(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getUniquePredecessor(), I, and llvm::Instruction::isTerminator().
Referenced by enableCallSafepoints().
INITIALIZE_PASS_BEGIN | ( | PlaceBackedgeSafepointsImpl | , |
"place-backedge-safepoints-impl" | , | ||
"Place Backedge Safepoints" | , | ||
false | , | ||
false | |||
) |
Referenced by llvm::createPlaceSafepointsPass().
place backedge safepoints Place Backedge false INITIALIZE_PASS_BEGIN | ( | PlaceSafepoints | , |
"place-safepoints" | , | ||
"Place Safepoints" | , | ||
false | , | ||
false | |||
) |
|
static |
Definition at line 624 of file PlaceSafepoints.cpp.
References assert(), llvm::BasicBlock::begin(), llvm::CallInst::Create(), llvm::Function::empty(), llvm::BasicBlock::end(), llvm::FunctionType::get(), llvm::Module::getContext(), llvm::Module::getFunction(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getValueType(), llvm::Type::getVoidTy(), and llvm::InlineFunction().
Referenced by enableCallSafepoints().
Definition at line 442 of file PlaceSafepoints.cpp.
References llvm::StringRef::equals(), and llvm::Value::getName().
Referenced by enableCallSafepoints().
|
static |
Returns true if this loop is known to terminate in a finite number of iterations.
Note that this function may return false for a loop which does actual terminate in a finite constant number of iterations due to conservatism in the analysis.
Definition at line 243 of file PlaceSafepoints.cpp.
References CountedLoopTripWidth, llvm::ScalarEvolution::getCouldNotCompute(), llvm::ScalarEvolution::getExitCount(), llvm::ScalarEvolution::getMaxBackedgeTakenCount(), llvm::ConstantRange::getUnsignedMax(), llvm::ScalarEvolution::getUnsignedRange(), llvm::APInt::isIntN(), and llvm::LoopBase< BlockT, LoopT >::isLoopExiting().
|
static |
Definition at line 185 of file PlaceSafepoints.cpp.
References llvm::callsGCLeafFunction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, UseTy, InstrTy, CallTy, InvokeTy, IterTy >::isCall(), llvm::isGCRelocate(), llvm::isGCResult(), llvm::CallInst::isInlineAsm(), and llvm::isStatepoint().
Referenced by containsUnconditionalCallSafepoint().
|
static |
Definition at line 295 of file PlaceSafepoints.cpp.
|
static |
Definition at line 268 of file PlaceSafepoints.cpp.
Returns true if this function should be rewritten to include safepoint polls and parseable call sites.
The main point of this function is to be an extension point for custom logic.
Definition at line 449 of file PlaceSafepoints.cpp.
References llvm::Function::getGC(), and llvm::Function::hasGC().
Referenced by enableCallSafepoints().
STATISTIC | ( | NumEntrySafepoints | , |
"Number of entry safepoints inserted" | |||
) |
STATISTIC | ( | NumBackedgeSafepoints | , |
"Number of backedge safepoints inserted" | |||
) |
STATISTIC | ( | CallInLoop | , |
"Number of loops without safepoints due to calls in loop" | |||
) |
STATISTIC | ( | FiniteExecution | , |
"Number of loops without safepoints finite execution" | |||
) |
|
static |
How narrow does the trip count of a loop have to be to have to be considered "counted"? Counted loops do not get safepoints at backedges.
Referenced by mustBeFiniteCountedLoop().
place backedge safepoints Place Backedge false place Place false |
Definition at line 615 of file PlaceSafepoints.cpp.
Definition at line 440 of file PlaceSafepoints.cpp.
place backedge safepoints impl |
Definition at line 615 of file PlaceSafepoints.cpp.
Referenced by enableBackedgeSafepoints().
Referenced by enableCallSafepoints().
Referenced by enableEntrySafepoints().
place backedge safepoints Place Backedge false place Place Safepoints |
Definition at line 615 of file PlaceSafepoints.cpp.
place backedge safepoints Place Backedge false place safepoints |
Definition at line 620 of file PlaceSafepoints.cpp.
Referenced by enableCallSafepoints().