LLVM  14.0.0git
Macros | Functions | Variables
PlaceSafepoints.cpp File Reference
#include "llvm/InitializePasses.h"
#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/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"
Include dependency graph for PlaceSafepoints.cpp:

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< CallBase * > &ParsePointsNeeded, const TargetLibraryInfo &TLI)
 
static bool needsStatepoint (CallBase *Call, 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 (CallBase *Call)
 Returns true if an entry safepoint is not required before this callsite in the caller function. More...
 
static InstructionfindLocationForEntrySafepoint (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< intCountedLoopTripWidth ("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))
 
const char 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
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "safepoint-placement"

Definition at line 69 of file PlaceSafepoints.cpp.

Function Documentation

◆ containsUnconditionalCallSafepoint()

static bool containsUnconditionalCallSafepoint ( Loop L,
BasicBlock Header,
BasicBlock Pred,
DominatorTree DT,
const TargetLibraryInfo TLI 
)
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 200 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().

◆ doesNotRequireEntrySafepointBefore()

static bool doesNotRequireEntrySafepointBefore ( CallBase Call)
static

Returns true if an entry safepoint is not required before this callsite in the caller function.

Definition at line 362 of file PlaceSafepoints.cpp.

Referenced by findLocationForEntrySafepoint().

◆ enableBackedgeSafepoints()

static bool enableBackedgeSafepoints ( Function F)
static

Definition at line 462 of file PlaceSafepoints.cpp.

References NoBackedge.

◆ enableCallSafepoints()

static bool enableCallSafepoints ( Function F)
static

Definition at line 463 of file PlaceSafepoints.cpp.

References NoCall.

◆ enableEntrySafepoints()

static bool enableEntrySafepoints ( Function F)
static

Definition at line 461 of file PlaceSafepoints.cpp.

References NoEntry.

◆ findLocationForEntrySafepoint()

static Instruction* findLocationForEntrySafepoint ( Function F,
DominatorTree DT 
)
static

◆ INITIALIZE_PASS_BEGIN() [1/2]

INITIALIZE_PASS_BEGIN ( PlaceBackedgeSafepointsImpl  ,
"place-backedge-safepoints-impl ,
"Place Backedge Safepoints ,
false  ,
false   
)

◆ INITIALIZE_PASS_BEGIN() [2/2]

place backedge safepoints Place Backedge false INITIALIZE_PASS_BEGIN ( PlaceSafepoints  ,
"place-safepoints ,
"Place Safepoints ,
false  ,
false   
)

◆ InsertSafepointPoll()

place backedge safepoints Place Backedge false place Place static false void InsertSafepointPoll ( Instruction InsertBefore,
std::vector< CallBase * > &  ParsePointsNeeded,
const TargetLibraryInfo TLI 
)
static

◆ isGCSafepointPoll()

static bool isGCSafepointPoll ( Function F)
static

Definition at line 440 of file PlaceSafepoints.cpp.

References F, and GCSafepointPollName.

◆ mustBeFiniteCountedLoop()

static bool mustBeFiniteCountedLoop ( Loop L,
ScalarEvolution SE,
BasicBlock Pred 
)
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 242 of file PlaceSafepoints.cpp.

References CountedLoopTripWidth, llvm::ScalarEvolution::getConstantMaxBackedgeTakenCount(), llvm::ScalarEvolution::getExitCount(), llvm::ConstantRange::getUnsignedMax(), llvm::ScalarEvolution::getUnsignedRange(), llvm::APInt::isIntN(), and llvm::LoopBase< BlockT, LoopT >::isLoopExiting().

◆ needsStatepoint()

static bool needsStatepoint ( CallBase Call,
const TargetLibraryInfo TLI 
)
static

Definition at line 184 of file PlaceSafepoints.cpp.

References llvm::callsGCLeafFunction().

Referenced by containsUnconditionalCallSafepoint().

◆ scanInlinedCode()

static void scanInlinedCode ( Instruction Start,
Instruction End,
std::vector< CallInst * > &  Calls,
DenseSet< BasicBlock * > &  Seen 
)
static

Definition at line 294 of file PlaceSafepoints.cpp.

◆ scanOneBB()

static void scanOneBB ( Instruction Start,
Instruction End,
std::vector< CallInst * > &  Calls,
DenseSet< BasicBlock * > &  Seen,
std::vector< BasicBlock * > &  Worklist 
)
static

Definition at line 267 of file PlaceSafepoints.cpp.

◆ shouldRewriteFunction()

static bool shouldRewriteFunction ( Function F)
static

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 447 of file PlaceSafepoints.cpp.

References F.

◆ STATISTIC() [1/4]

STATISTIC ( CallInLoop  ,
"Number of loops without safepoints due to calls in loop  
)

◆ STATISTIC() [2/4]

STATISTIC ( FiniteExecution  ,
"Number of loops without safepoints finite execution  
)

◆ STATISTIC() [3/4]

STATISTIC ( NumBackedgeSafepoints  ,
"Number of backedge safepoints inserted"   
)

◆ STATISTIC() [4/4]

STATISTIC ( NumEntrySafepoints  ,
"Number of entry safepoints inserted"   
)

Variable Documentation

◆ AllBackedges

cl::opt<bool> AllBackedges("spp-all-backedges", cl::Hidden, cl::init(false))
static

◆ CountedLoopTripWidth

cl::opt<int> CountedLoopTripWidth("spp-counted-loop-trip-width", cl::Hidden, cl::init(32))
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().

◆ false

place backedge safepoints Place Backedge false place Place false

Definition at line 613 of file PlaceSafepoints.cpp.

◆ GCSafepointPollName

const char GCSafepointPollName[] = "gc.safepoint_poll"

Definition at line 438 of file PlaceSafepoints.cpp.

Referenced by InsertSafepointPoll(), and isGCSafepointPoll().

◆ impl

place backedge safepoints impl

◆ NoBackedge

cl::opt<bool> NoBackedge("spp-no-backedge", cl::Hidden, cl::init(false))
static

◆ NoCall

cl::opt<bool> NoCall("spp-no-call", cl::Hidden, cl::init(false))
static

Referenced by enableCallSafepoints().

◆ NoEntry

cl::opt<bool> NoEntry("spp-no-entry", cl::Hidden, cl::init(false))
static

Referenced by enableEntrySafepoints().

◆ Safepoints

place backedge safepoints Place Backedge false place Place Safepoints

Definition at line 613 of file PlaceSafepoints.cpp.

◆ safepoints

place backedge safepoints Place Backedge false place safepoints

Definition at line 617 of file PlaceSafepoints.cpp.

◆ SplitBackedge

cl::opt<bool> SplitBackedge("spp-split-backedge", cl::Hidden, cl::init(false))
static