MLIR 22.0.0git
LocalAliasAnalysis.cpp File Reference
#include "mlir/Analysis/AliasAnalysis/LocalAliasAnalysis.h"
#include "mlir/Analysis/AliasAnalysis.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Block.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/Region.h"
#include "mlir/IR/Value.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Interfaces/ViewLikeInterface.h"
#include "mlir/Support/LLVM.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DebugLog.h"
#include <cassert>
#include <optional>
#include <utility>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "local-alias-analysis"

Functions

static void collectUnderlyingAddressValues (Value value, unsigned maxDepth, DenseSet< Value > &visited, SmallVectorImpl< Value > &output)
 Given a value, collect all of the underlying values being addressed.
static void collectUnderlyingAddressValues2 (RegionBranchOpInterface branch, RegionSuccessor initialSuccessor, Value inputValue, unsigned inputIndex, unsigned maxDepth, DenseSet< Value > &visited, SmallVectorImpl< Value > &output)
 Given a RegionBranchOpInterface operation (branch), a ValueinputValue which is an input for the provided successor (initialSuccessor), try to find the possible sources for the value along the control flow edges.
static void collectUnderlyingAddressValues (OpResult result, unsigned maxDepth, DenseSet< Value > &visited, SmallVectorImpl< Value > &output)
 Given a result, collect all of the underlying values being addressed.
static void collectUnderlyingAddressValues (BlockArgument arg, unsigned maxDepth, DenseSet< Value > &visited, SmallVectorImpl< Value > &output)
 Given a block argument, collect all of the underlying values being addressed.
static void collectUnderlyingAddressValues (Value value, SmallVectorImpl< Value > &output)
 Given a value, collect all of the underlying values being addressed.
static LogicalResult getAllocEffectFor (Value value, std::optional< MemoryEffects::EffectInstance > &effect, Operation *&allocScopeOp)
 Given a value, try to get an allocation effect attached to it.
static OperationisDistinctObjectsOp (Operation *op)
static Value getDistinctObjectsOperand (Operation *op, Value value)
static std::optional< AliasResultcheckDistinctObjects (Value lhs, Value rhs)

Variables

static constexpr unsigned maxUnderlyingValueSearchDepth = 10
 The maximum depth that will be searched when trying to find an underlying value.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "local-alias-analysis"

Definition at line 32 of file LocalAliasAnalysis.cpp.

Function Documentation

◆ checkDistinctObjects()

std::optional< AliasResult > checkDistinctObjects ( Value lhs,
Value rhs )
static

◆ collectUnderlyingAddressValues() [1/4]

void collectUnderlyingAddressValues ( BlockArgument arg,
unsigned maxDepth,
DenseSet< Value > & visited,
SmallVectorImpl< Value > & output )
static

◆ collectUnderlyingAddressValues() [2/4]

void collectUnderlyingAddressValues ( OpResult result,
unsigned maxDepth,
DenseSet< Value > & visited,
SmallVectorImpl< Value > & output )
static

Given a result, collect all of the underlying values being addressed.

Definition at line 92 of file LocalAliasAnalysis.cpp.

References collectUnderlyingAddressValues(), collectUnderlyingAddressValues2(), mlir::Operation::getResults(), and result.

◆ collectUnderlyingAddressValues() [3/4]

void collectUnderlyingAddressValues ( Value value,
SmallVectorImpl< Value > & output )
static

Given a value, collect all of the underlying values being addressed.

Definition at line 228 of file LocalAliasAnalysis.cpp.

References collectUnderlyingAddressValues(), and maxUnderlyingValueSearchDepth.

◆ collectUnderlyingAddressValues() [4/4]

void collectUnderlyingAddressValues ( Value value,
unsigned maxDepth,
DenseSet< Value > & visited,
SmallVectorImpl< Value > & output )
static

◆ collectUnderlyingAddressValues2()

void collectUnderlyingAddressValues2 ( RegionBranchOpInterface branch,
RegionSuccessor initialSuccessor,
Value inputValue,
unsigned inputIndex,
unsigned maxDepth,
DenseSet< Value > & visited,
SmallVectorImpl< Value > & output )
static

Given a RegionBranchOpInterface operation (branch), a ValueinputValue which is an input for the provided successor (initialSuccessor), try to find the possible sources for the value along the control flow edges.

Definition at line 50 of file LocalAliasAnalysis.cpp.

References collectUnderlyingAddressValues(), and mlir::RegionSuccessor::getSuccessorInputs().

Referenced by collectUnderlyingAddressValues(), and collectUnderlyingAddressValues().

◆ getAllocEffectFor()

LogicalResult getAllocEffectFor ( Value value,
std::optional< MemoryEffects::EffectInstance > & effect,
Operation *& allocScopeOp )
static

Given a value, try to get an allocation effect attached to it.

If successful, allocEffect is populated with the effect. If an effect was found, allocScopeOp is also specified if a parent operation of value could be identified that bounds the scope of the allocated value; i.e. if non-null it specifies the parent operation that the allocation does not escape. If no scope is found, allocScopeOp is set to nullptr.

Definition at line 248 of file LocalAliasAnalysis.cpp.

References mlir::Operation::getParentOp(), and success().

Referenced by mlir::LocalAliasAnalysis::aliasImpl().

◆ getDistinctObjectsOperand()

Value getDistinctObjectsOperand ( Operation * op,
Value value )
static

Definition at line 315 of file LocalAliasAnalysis.cpp.

References mlir::Operation::getOperand().

Referenced by checkDistinctObjects().

◆ isDistinctObjectsOp()

Operation * isDistinctObjectsOp ( Operation * op)
static

Definition at line 308 of file LocalAliasAnalysis.cpp.

References mlir::Operation::hasTrait().

Referenced by checkDistinctObjects().

Variable Documentation

◆ maxUnderlyingValueSearchDepth

unsigned maxUnderlyingValueSearchDepth = 10
staticconstexpr

The maximum depth that will be searched when trying to find an underlying value.

Definition at line 40 of file LocalAliasAnalysis.cpp.

Referenced by collectUnderlyingAddressValues().