|
LLVM
3.7.0
|
#include "llvm/Pass.h"#include "llvm/IR/LegacyPassManager.h"#include "llvm/ADT/SetOperations.h"#include "llvm/ADT/SetVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/ADT/StringRef.h"#include "llvm/Analysis/LoopPass.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/Analysis/ScalarEvolution.h"#include "llvm/Analysis/ScalarEvolutionExpressions.h"#include "llvm/Analysis/CFG.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/CallSite.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/Function.h"#include "llvm/IR/IRBuilder.h"#include "llvm/IR/InstIterator.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Module.h"#include "llvm/IR/Statepoint.h"#include "llvm/IR/Value.h"#include "llvm/IR/Verifier.h"#include "llvm/Support/Debug.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Scalar.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/Transforms/Utils/Cloning.h"#include "llvm/Transforms/Utils/Local.h"Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "safepoint-placement" |
Functions | |
| STATISTIC (NumEntrySafepoints,"Number of entry safepoints inserted") | |
| STATISTIC (NumCallSafepoints,"Number of call safepoints inserted") | |
| STATISTIC (NumBackedgeSafepoints,"Number of backedge safepoints inserted") | |
| STATISTIC (CallInLoop,"Number of loops w/o safepoints due to calls in loop") | |
| STATISTIC (FiniteExecution,"Number of loops w/o safepoints finite execution") | |
| static void | InsertSafepointPoll (Instruction *InsertBefore, std::vector< CallSite > &ParsePointsNeeded) |
| static bool | isGCLeafFunction (const CallSite &CS) |
| static bool | needsStatepoint (const CallSite &CS) |
| static Value * | ReplaceWithStatepoint (const CallSite &CS,Pass *P) |
| Replaces the given call site (Call or Invoke) with a gc.statepoint intrinsic with an empty deoptimization arguments list. More... | |
| static bool | containsUnconditionalCallSafepoint (Loop *L, BasicBlock *Header, BasicBlock *Pred, DominatorTree &DT) |
| 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, std::set< BasicBlock * > &seen, std::vector< BasicBlock * > &worklist) |
| static void | scanInlinedCode (Instruction *start, Instruction *end, std::vector< CallInst * > &calls, std::set< 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 void | findCallSafepoints (Function &F, std::vector< CallSite > &Found) |
| Identify the list of call sites which need to be have parseable state. More... | |
| template<typename T > | |
| static void | unique_unsorted (std::vector< T > &vec) |
| Implement a unique function which doesn't require we sort the input vector. More... | |
| 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) |
| static BasicBlock * | normalizeForInvokeSafepoint (BasicBlock *BB, BasicBlock *InvokeParent) |
| 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< bool > | SkipCounted ("spp-counted", cl::Hidden, cl::init(true)) |
| If true, do not place backedge safepoints in counted loops. More... | |
| static cl::opt< bool > | SplitBackedge ("spp-split-backedge", cl::Hidden, cl::init(false)) |
| static cl::opt< bool > | TraceLSP ("spp-trace", 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 84 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 215 of file PlaceSafepoints.cpp.
References llvm::CS, llvm::DominatorTree::dominates(), llvm::DomTreeNodeBase< T >::getBlock(), llvm::DomTreeNodeBase< T >::getIDom(), llvm::DominatorTreeBase< N >::getNode(), I, and needsStatepoint().
Returns true if an entry safepoint is not required before this callsite in the caller function.
Definition at line 387 of file PlaceSafepoints.cpp.
References llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction().
Referenced by findLocationForEntrySafepoint().
Definition at line 523 of file PlaceSafepoints.cpp.
References NoBackedge.
Definition at line 524 of file PlaceSafepoints.cpp.
References NoCall.
Definition at line 522 of file PlaceSafepoints.cpp.
References NoEntry.
Identify the list of call sites which need to be have parseable state.
Definition at line 466 of file PlaceSafepoints.cpp.
References llvm::CS, I, llvm::inst_range(), and needsStatepoint().
|
static |
Definition at line 411 of file PlaceSafepoints.cpp.
References llvm::BasicBlock::begin(), llvm::CS, doesNotRequireEntrySafepointBefore(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getUniquePredecessor(), I, and llvm::Instruction::isTerminator().
| INITIALIZE_PASS_BEGIN | ( | PlaceBackedgeSafepointsImpl | , |
| "place-backedge-safepoints-impl" | , | ||
| "Place Backedge Safepoints" | , | ||
| false | , | ||
| false | |||
| ) |
| place backedge safepoints Place Backedge false INITIALIZE_PASS_BEGIN | ( | PlaceSafepoints | , |
| "place-safepoints" | , | ||
| "Place Safepoints" | , | ||
| false | , | ||
| false | |||
| ) |
|
static |
Definition at line 788 of file PlaceSafepoints.cpp.
References llvm::BasicBlock::begin(), llvm::CallInst::Create(), llvm::Function::empty(), llvm::BasicBlock::end(), GCSafepointPollName, llvm::FunctionType::get(), llvm::Module::getContext(), llvm::SequentialType::getElementType(), llvm::Module::getFunction(), llvm::Instruction::getModule(), llvm::Instruction::getParent(), llvm::GlobalValue::getType(), llvm::Type::getVoidTy(), llvm::InlineFunction(), llvm::isPotentiallyReachable(), needsStatepoint(), and scanInlinedCode().
|
static |
Definition at line 762 of file PlaceSafepoints.cpp.
References llvm::StringRef::equals(), llvm::Function::getFnAttribute(), llvm::Attribute::getValueAsString(), and llvm::Intrinsic::isLeaf().
Referenced by needsStatepoint().
Definition at line 501 of file PlaceSafepoints.cpp.
References llvm::StringRef::equals(), GCSafepointPollName, and llvm::Value::getName().
|
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 256 of file PlaceSafepoints.cpp.
References llvm::ScalarEvolution::getCouldNotCompute(), llvm::ScalarEvolution::getExitCount(), llvm::ScalarEvolution::getMaxBackedgeTakenCount(), llvm::ConstantRange::getUnsignedMax(), llvm::ScalarEvolution::getUnsignedRange(), llvm::APInt::isIntN(), llvm::LoopBase< N, M >::isLoopExiting(), SkipCounted, and llvm::APInt::ult().
Definition at line 195 of file PlaceSafepoints.cpp.
References llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::isCall(), isGCLeafFunction(), llvm::isGCRelocate(), llvm::isGCResult(), llvm::CallInst::isInlineAsm(), and llvm::isStatepoint().
Referenced by containsUnconditionalCallSafepoint(), findCallSafepoints(), and InsertSafepointPoll().
|
static |
Definition at line 528 of file PlaceSafepoints.cpp.
References llvm::BasicBlock::begin(), llvm::FoldSingleEntryPHINodes(), llvm::BasicBlock::getUniquePredecessor(), and llvm::SplitBlockPredecessors().
Replaces the given call site (Call or Invoke) with a gc.statepoint intrinsic with an empty deoptimization arguments list.
This does NOT do explicit relocation for GC support.
Definition at line 867 of file PlaceSafepoints.cpp.
References llvm::AttrBuilder::addAttribute(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_begin(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::arg_end(), llvm::BasicBlock::begin(), llvm::Call, llvm::AttributeSet::FunctionIndex, llvm::ConstantPointerNull::get(), llvm::StringRef::getAsInteger(), llvm::AttributeSet::getAttribute(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getAttributes(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledValue(), llvm::CallInst::getCallingConv(), llvm::InvokeInst::getCallingConv(), llvm::Value::getContext(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getFirstInsertionPt(), llvm::AttributeSet::getFnAttributes(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::Value::getName(), llvm::ilist_node< NodeTy >::getNextNode(), llvm::InvokeInst::getNormalDest(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::AttributeSet::getRetAttributes(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getType(), llvm::Value::getType(), llvm::InvokeInst::getUnwindDest(), llvm::Attribute::getValueAsString(), llvm::Value::hasName(), llvm::IP, llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::isCall(), llvm::CallSiteBase< FunTy, BBTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::isInvoke(), llvm::Attribute::isStringAttribute(), llvm::CallInst::isTailCall(), llvm::Type::isVoidTy(), llvm_unreachable, llvm::makeArrayRef(), llvm::None, llvm::AttributeSet::removeAttributes(), llvm::CallInst::setAttributes(), llvm::InvokeInst::setAttributes(), llvm::InvokeInst::setCallingConv(), and llvm::Value::use_empty().
|
static |
Definition at line 316 of file PlaceSafepoints.cpp.
References llvm::BasicBlock::back(), llvm::BasicBlock::begin(), llvm::sys::path::end(), llvm::Instruction::getParent(), and scanOneBB().
Referenced by InsertSafepointPoll().
|
static |
Definition at line 290 of file PlaceSafepoints.cpp.
References llvm::BasicBlock::end(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), and llvm::successors().
Referenced by scanInlinedCode().
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 508 of file PlaceSafepoints.cpp.
References llvm::Function::getGC(), and llvm::Function::hasGC().
| STATISTIC | ( | NumEntrySafepoints | , |
| "Number of entry safepoints inserted" | |||
| ) |
| STATISTIC | ( | NumCallSafepoints | , |
| "Number of call safepoints inserted" | |||
| ) |
| STATISTIC | ( | NumBackedgeSafepoints | , |
| "Number of backedge safepoints inserted" | |||
| ) |
| STATISTIC | ( | CallInLoop | , |
| "Number of loops w/o safepoints due to calls in loop" | |||
| ) |
| STATISTIC | ( | FiniteExecution | , |
| "Number of loops w/o safepoints finite execution" | |||
| ) |
|
static |
Implement a unique function which doesn't require we sort the input vector.
Doing so has the effect of changing the output of a couple of tests in ways which make them less useful in testing fused safepoints.
Definition at line 487 of file PlaceSafepoints.cpp.
References std::swap().
| place backedge safepoints Place Backedge false place Place false |
Definition at line 754 of file PlaceSafepoints.cpp.
Definition at line 499 of file PlaceSafepoints.cpp.
Referenced by InsertSafepointPoll(), and isGCSafepointPoll().
| place backedge safepoints impl |
Definition at line 754 of file PlaceSafepoints.cpp.
Referenced by llvm::RuntimeDyldMachOCRTPBase< Impl >::finalizeLoad().
Referenced by enableBackedgeSafepoints().
Referenced by enableCallSafepoints().
Referenced by enableEntrySafepoints().
| place backedge safepoints Place Backedge false place Place Safepoints |
Definition at line 754 of file PlaceSafepoints.cpp.
| place backedge safepoints Place Backedge false place safepoints |
Definition at line 759 of file PlaceSafepoints.cpp.
If true, do not place backedge safepoints in counted loops.
Referenced by mustBeFiniteCountedLoop().
1.8.6