LLVM 17.0.0git
Macros | Functions | Variables
MustExecute.cpp File Reference
#include "llvm/Analysis/MustExecute.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/AssemblyAnnotationWriter.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/raw_ostream.h"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "must-execute"
 

Functions

static bool CanProveNotTakenFirstIteration (const BasicBlock *ExitBlock, const DominatorTree *DT, const Loop *CurLoop)
 Return true if we can prove that the given ExitBlock is not reached on the first iteration of the given loop.
 
static void collectTransitivePredecessors (const Loop *CurLoop, const BasicBlock *BB, SmallPtrSetImpl< const BasicBlock * > &Predecessors)
 Collect all blocks from CurLoop which lie on all possible paths from the header of CurLoop (inclusive) to BB (exclusive) into the set Predecessors.
 
 INITIALIZE_PASS_BEGIN (MustExecutePrinter, "print-mustexecute", "Instructions which execute on loop entry", false, true) INITIALIZE_PASS_END(MustExecutePrinter
 
 INITIALIZE_PASS_BEGIN (MustBeExecutedContextPrinter, "print-must-be-executed-contexts", "print the must-be-executed-context for all instructions", false, true) INITIALIZE_PASS_END(MustBeExecutedContextPrinter
 
static bool isMustExecuteIn (const Instruction &I, Loop *L, DominatorTree *DT)
 
static bool maybeEndlessLoop (const Loop &L)
 Return true if L might be an endless loop.
 
template<typename K , typename V , typename FnTy , typename... ArgsTy>
static V getOrCreateCachedOptional (K Key, DenseMap< K, std::optional< V > > &Map, FnTy &&Fn, ArgsTy &&...args)
 Lookup Key in Map and return the result, potentially after initializing the optional through Fn(args).
 

Variables

print mustexecute
 
print Instructions which execute on loop entry
 
print Instructions which execute on loop false
 
print must be executed contexts
 
print must be executed print the must be executed context for all instructions
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "must-execute"

Definition at line 29 of file MustExecute.cpp.

Function Documentation

◆ CanProveNotTakenFirstIteration()

static bool CanProveNotTakenFirstIteration ( const BasicBlock ExitBlock,
const DominatorTree DT,
const Loop CurLoop 
)
static

Return true if we can prove that the given ExitBlock is not reached on the first iteration of the given loop.

That is, the backedge of the loop must be executed before the ExitBlock is executed in any dynamic execution trace.

Definition at line 117 of file MustExecute.cpp.

References assert(), Cond, llvm::LoopBase< BlockT, LoopT >::contains(), DL, llvm::Module::getDataLayout(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::BasicBlock::getModule(), llvm::BasicBlock::getSinglePredecessor(), LHS, RHS, and llvm::simplifyCmpInst().

Referenced by llvm::LoopSafetyInfo::allLoopPathsLeadToBlock().

◆ collectTransitivePredecessors()

static void collectTransitivePredecessors ( const Loop CurLoop,
const BasicBlock BB,
SmallPtrSetImpl< const BasicBlock * > &  Predecessors 
)
static

◆ getOrCreateCachedOptional()

template<typename K , typename V , typename FnTy , typename... ArgsTy>
static V getOrCreateCachedOptional ( Key,
DenseMap< K, std::optional< V > > &  Map,
FnTy &&  Fn,
ArgsTy &&...  args 
)
static

Lookup Key in Map and return the result, potentially after initializing the optional through Fn(args).

Definition at line 501 of file MustExecute.cpp.

References args.

Referenced by llvm::MustBeExecutedContextExplorer::findForwardJoinPoint().

◆ INITIALIZE_PASS_BEGIN() [1/2]

INITIALIZE_PASS_BEGIN ( MustBeExecutedContextPrinter  ,
"print-must-be-executed-contexts"  ,
"print the must-be-executed-context for all instructions"  ,
false  ,
true   
)

◆ INITIALIZE_PASS_BEGIN() [2/2]

INITIALIZE_PASS_BEGIN ( MustExecutePrinter  ,
"print-mustexecute"  ,
"Instructions which execute on loop entry"  ,
false  ,
true   
)

◆ isMustExecuteIn()

static bool isMustExecuteIn ( const Instruction I,
Loop L,
DominatorTree DT 
)
static

◆ maybeEndlessLoop()

static bool maybeEndlessLoop ( const Loop L)
static

Return true if L might be an endless loop.

Definition at line 481 of file MustExecute.cpp.

Referenced by llvm::MustBeExecutedContextExplorer::findForwardJoinPoint().

Variable Documentation

◆ contexts

print must be executed contexts

Definition at line 361 of file MustExecute.cpp.

◆ entry

print Instructions which execute on loop entry

◆ false

print must be executed print the must be executed context for all false

Definition at line 346 of file MustExecute.cpp.

◆ instructions

print must be executed print the must be executed context for all instructions

Definition at line 362 of file MustExecute.cpp.

Referenced by addBoundsChecking(), addMustTailToCoroResumes(), llvm::X86TTIImpl::areInlineCompatible(), bitTrackingDCE(), llvm::coro::buildCoroutineFrame(), llvm::coro::Shape::buildFrom(), llvm::Function::callsFunctionThatReturnsTwice(), canTRE(), checkFunctionMemoryAccess(), collectDbgVariableIntrinsics(), computeUsesMSVCFloatingPoint(), convertAnnotation2Metadata(), createSCCNodeSet(), doRematerializations(), eliminateDeadCode(), eraseDebugIntrinsicsWithNonLocalRefs(), explicifyGuards(), fixupDebugInfoPostExtraction(), functionWillReturn(), getEdgeKind(), llvm::GenericUniformityAnalysisImpl< ContextT >::initialize(), INITIALIZE_PASS(), llvm::InformationCache::initializeModuleSlice(), llvm::MLInlineAdvisor::MLInlineAdvisor(), llvm::InstDeleterIRStrategy::mutate(), llvm::StackSafetyGlobalInfo::print(), llvm::ScalarEvolution::print(), processDbgDeclares(), removeTailCallAttribute(), llvm::replaceCreatedSSACopys(), rescheduleLexographically(), llvm::AliasSetsPrinterPass::run(), llvm::MemDerefPrinterPass::run(), llvm::StackLifetimePrinterPass::run(), llvm::KCFIPass::run(), llvm::PAEvalPass::run(), llvm::AssumeBuilderPass::run(), llvm::AMDGPULowerKernelAttributesPass::run(), llvm::DSEPass::run(), llvm::InlinerPass::run(), llvm::DevirtSCCRepeatedPass::run(), llvm::ModuleInlinerPass::run(), llvm::MustBeExecutedContextPrinterPass::run(), runImpl(), runNVVMIntrRange(), llvm::RewriteStatepointsForGC::runOnFunction(), runPass(), sinkLifetimeStartMarkers(), stripDeadDebugInfoImpl(), stripGCRelocates(), stripNonValidDataFromBody(), stripTBAA(), and updateCGAndAnalysisManagerForPass().

◆ mustexecute

print mustexecute

Definition at line 345 of file MustExecute.cpp.