LLVM 19.0.0git
Public Member Functions | List of all members
llvm::ImplicitControlFlowTracking Class Reference

This class allows to keep track on instructions with implicit control flow. More...

#include "llvm/Analysis/InstructionPrecedenceTracking.h"

Inheritance diagram for llvm::ImplicitControlFlowTracking:
Inheritance graph
[legend]

Public Member Functions

const InstructiongetFirstICFI (const BasicBlock *BB)
 Returns the topmost instruction with implicit control flow from the given basic block.
 
bool hasICF (const BasicBlock *BB)
 Returns true if at least one instruction from the given basic block has implicit control flow.
 
bool isDominatedByICFIFromSameBlock (const Instruction *Insn)
 Returns true if the first ICFI of Insn's block exists and dominates Insn.
 
bool isSpecialInstruction (const Instruction *Insn) const override
 A predicate that defines whether or not the instruction Insn is considered special and needs to be tracked.
 
- Public Member Functions inherited from llvm::InstructionPrecedenceTracking
void insertInstructionTo (const Instruction *Inst, const BasicBlock *BB)
 Notifies this tracking that we are going to insert a new instruction Inst to the basic block BB.
 
void removeInstruction (const Instruction *Inst)
 Notifies this tracking that we are going to remove the instruction Inst It makes all necessary updates to internal caches to keep them consistent.
 
void removeUsersOf (const Instruction *Inst)
 Notifies this tracking that we are going to replace all uses of Inst.
 
void clear ()
 Invalidates all information from this tracking.
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::InstructionPrecedenceTracking
const InstructiongetFirstSpecialInstruction (const BasicBlock *BB)
 Returns the topmost special instruction from the block BB.
 
bool hasSpecialInstructions (const BasicBlock *BB)
 Returns true iff at least one instruction from the basic block BB is special.
 
bool isPreceededBySpecialInstruction (const Instruction *Insn)
 Returns true iff the first special instruction of Insn's block exists and dominates Insn.
 
virtual bool isSpecialInstruction (const Instruction *Insn) const =0
 A predicate that defines whether or not the instruction Insn is considered special and needs to be tracked.
 
virtual ~InstructionPrecedenceTracking ()=default
 

Detailed Description

This class allows to keep track on instructions with implicit control flow.

These are instructions that may not pass execution to their successors. For example, throwing calls and guards do not always do this. If we need to know for sure that some instruction is guaranteed to execute if the given block is reached, then we need to make sure that there is no implicit control flow instruction (ICFI) preceding it. For example, this check is required if we perform PRE moving non-speculable instruction to other place.

Definition at line 99 of file InstructionPrecedenceTracking.h.

Member Function Documentation

◆ getFirstICFI()

const Instruction * llvm::ImplicitControlFlowTracking::getFirstICFI ( const BasicBlock BB)
inline

Returns the topmost instruction with implicit control flow from the given basic block.

Returns nullptr if there is no such instructions in the block.

Definition at line 103 of file InstructionPrecedenceTracking.h.

References llvm::InstructionPrecedenceTracking::getFirstSpecialInstruction().

◆ hasICF()

bool llvm::ImplicitControlFlowTracking::hasICF ( const BasicBlock BB)
inline

Returns true if at least one instruction from the given basic block has implicit control flow.

Definition at line 109 of file InstructionPrecedenceTracking.h.

References llvm::InstructionPrecedenceTracking::hasSpecialInstructions().

Referenced by llvm::ICFLoopSafetyInfo::blockMayThrow(), and llvm::ICFLoopSafetyInfo::computeLoopSafetyInfo().

◆ isDominatedByICFIFromSameBlock()

bool llvm::ImplicitControlFlowTracking::isDominatedByICFIFromSameBlock ( const Instruction Insn)
inline

Returns true if the first ICFI of Insn's block exists and dominates Insn.

Definition at line 114 of file InstructionPrecedenceTracking.h.

References Insn, and llvm::InstructionPrecedenceTracking::isPreceededBySpecialInstruction().

Referenced by llvm::ICFLoopSafetyInfo::isGuaranteedToExecute().

◆ isSpecialInstruction()

bool ImplicitControlFlowTracking::isSpecialInstruction ( const Instruction Insn) const
overridevirtual

A predicate that defines whether or not the instruction Insn is considered special and needs to be tracked.

Implementing this method in children classes allows to implement tracking of implicit control flow, memory writing instructions or any other kinds of instructions we might be interested in.

Implements llvm::InstructionPrecedenceTracking.

Definition at line 137 of file InstructionPrecedenceTracking.cpp.

References Insn, and llvm::isGuaranteedToTransferExecutionToSuccessor().


The documentation for this class was generated from the following files: