LLVM 19.0.0git
Functions
Analysis.cpp File Reference
#include "llvm/CodeGen/Analysis.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetMachine.h"

Go to the source code of this file.

Functions

static bool isNoopBitcast (Type *T1, Type *T2, const TargetLoweringBase &TLI)
 
static const ValuegetNoopInput (const Value *V, SmallVectorImpl< unsigned > &ValLoc, unsigned &DataBits, const TargetLoweringBase &TLI, const DataLayout &DL)
 Look through operations that will be free to find the earliest source of this value.
 
static bool slotOnlyDiscardsData (const Value *RetVal, const Value *CallVal, SmallVectorImpl< unsigned > &RetIndices, SmallVectorImpl< unsigned > &CallIndices, bool AllowDifferingSizes, const TargetLoweringBase &TLI, const DataLayout &DL)
 Return true if this scalar return value only has bits discarded on its path from the "tail call" to the "ret".
 
static bool indexReallyValid (Type *T, unsigned Idx)
 For an aggregate type, determine whether a given index is within bounds or not.
 
static bool advanceToNextLeafType (SmallVectorImpl< Type * > &SubTypes, SmallVectorImpl< unsigned > &Path)
 Move the given iterators to the next leaf type in depth first traversal.
 
static bool firstRealType (Type *Next, SmallVectorImpl< Type * > &SubTypes, SmallVectorImpl< unsigned > &Path)
 Find the first non-empty, scalar-like type in Next and setup the iterator components.
 
static bool nextRealType (SmallVectorImpl< Type * > &SubTypes, SmallVectorImpl< unsigned > &Path)
 Set the iterator data-structures to the next non-empty, non-aggregate subtype.
 
static bool isPointerBitcastEqualTo (const Value *A, const Value *B)
 Check whether B is a bitcast of a pointer type to another pointer type, which is equal to A.
 
static void collectEHScopeMembers (DenseMap< const MachineBasicBlock *, int > &EHScopeMembership, int EHScope, const MachineBasicBlock *MBB)
 

Function Documentation

◆ advanceToNextLeafType()

static bool advanceToNextLeafType ( SmallVectorImpl< Type * > &  SubTypes,
SmallVectorImpl< unsigned > &  Path 
)
static

Move the given iterators to the next leaf type in depth first traversal.

Performs a depth-first traversal of the type as specified by its arguments, stopping at the next leaf node (which may be a legitimate scalar type or an empty struct or array).

Parameters
SubTypesList of the partial components making up the type from outermost to innermost non-empty aggregate. The element currently represented is SubTypes.back()->getTypeAtIndex(Path.back() - 1).
PathSet of extractvalue indices leading from the outermost type (SubTypes[0]) to the leaf node currently represented.
Returns
true if a new type was found, false otherwise. Calling this function again on a finished iterator will repeatedly return false. SubTypes.back()->getTypeAtIndex(Path.back()) is either an empty aggregate or a non-aggregate

Definition at line 445 of file Analysis.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::ExtractValueInst::getIndexedType(), indexReallyValid(), llvm::Type::isAggregateType(), llvm::SmallVectorTemplateBase< T, bool >::pop_back(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by firstRealType(), and nextRealType().

◆ collectEHScopeMembers()

static void collectEHScopeMembers ( DenseMap< const MachineBasicBlock *, int > &  EHScopeMembership,
int  EHScope,
const MachineBasicBlock MBB 
)
static

◆ firstRealType()

static bool firstRealType ( Type Next,
SmallVectorImpl< Type * > &  SubTypes,
SmallVectorImpl< unsigned > &  Path 
)
static

Find the first non-empty, scalar-like type in Next and setup the iterator components.

Assuming Next is an aggregate of some kind, this function will traverse the tree from left to right (i.e. depth-first) looking for the first non-aggregate type which will play a role in function return.

For example, if Next was {[0 x i64], {{}, i32, {}}, i32} then we would setup Path as [1, 1] and SubTypes as [Next, {{}, i32, {}}] to represent the first i32 in that type.

Definition at line 486 of file Analysis.cpp.

References advanceToNextLeafType(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::ExtractValueInst::getIndexedType(), llvm::Type::isAggregateType(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by llvm::returnTypeIsEligibleForTailCall().

◆ getNoopInput()

static const Value * getNoopInput ( const Value V,
SmallVectorImpl< unsigned > &  ValLoc,
unsigned DataBits,
const TargetLoweringBase TLI,
const DataLayout DL 
)
static

Look through operations that will be free to find the earliest source of this value.

Parameters
ValLocIf V has aggregate type, we will be interested in a particular scalar component. This records its address; the reverse of this list gives a sequence of indices appropriate for an extractvalue to locate the important value. This value is updated during the function and on exit will indicate similar information for the Value returned.
DataBitsIf this function looks through truncate instructions, this will record the smallest size attained.

Definition at line 295 of file Analysis.cpp.

References llvm::TargetLoweringBase::allowTruncateForTailCall(), llvm::SmallVectorImpl< T >::append(), llvm::ArrayRef< T >::begin(), DL, llvm::ArrayRef< T >::end(), llvm::Value::getType(), I, isNoopBitcast(), llvm::SmallVectorTemplateCommon< T, typename >::rbegin(), llvm::ArrayRef< T >::rbegin(), llvm::ArrayRef< T >::rend(), llvm::SmallVectorImpl< T >::resize(), llvm::ArrayRef< T >::size(), and llvm::SmallVectorBase< Size_T >::size().

Referenced by slotOnlyDiscardsData().

◆ indexReallyValid()

static bool indexReallyValid ( Type T,
unsigned  Idx 
)
static

For an aggregate type, determine whether a given index is within bounds or not.

Definition at line 421 of file Analysis.cpp.

References Idx.

Referenced by advanceToNextLeafType().

◆ isNoopBitcast()

static bool isNoopBitcast ( Type T1,
Type T2,
const TargetLoweringBase TLI 
)
static

◆ isPointerBitcastEqualTo()

static bool isPointerBitcastEqualTo ( const Value A,
const Value B 
)
static

Check whether B is a bitcast of a pointer type to another pointer type, which is equal to A.

Definition at line 642 of file Analysis.cpp.

References A, assert(), and B.

Referenced by llvm::returnTypeIsEligibleForTailCall().

◆ nextRealType()

static bool nextRealType ( SmallVectorImpl< Type * > &  SubTypes,
SmallVectorImpl< unsigned > &  Path 
)
static

Set the iterator data-structures to the next non-empty, non-aggregate subtype.

Definition at line 515 of file Analysis.cpp.

References advanceToNextLeafType(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::ExtractValueInst::getIndexedType(), and llvm::Type::isAggregateType().

Referenced by llvm::returnTypeIsEligibleForTailCall().

◆ slotOnlyDiscardsData()

static bool slotOnlyDiscardsData ( const Value RetVal,
const Value CallVal,
SmallVectorImpl< unsigned > &  RetIndices,
SmallVectorImpl< unsigned > &  CallIndices,
bool  AllowDifferingSizes,
const TargetLoweringBase TLI,
const DataLayout DL 
)
static

Return true if this scalar return value only has bits discarded on its path from the "tail call" to the "ret".

This includes the obvious noop instructions handled by getNoopInput above as well as free truncations (or extensions prior to the call).

Definition at line 377 of file Analysis.cpp.

References DL, and getNoopInput().

Referenced by llvm::returnTypeIsEligibleForTailCall().