LLVM  14.0.0git
Namespaces | Macros | Functions | Variables
InferAddressSpaces.cpp File Reference
#include "llvm/Transforms/Scalar/InferAddressSpaces.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
#include <cassert>
#include <iterator>
#include <limits>
#include <utility>
#include <vector>
Include dependency graph for InferAddressSpaces.cpp:

Go to the source code of this file.

Namespaces

 llvm
 This file implements support for optimizing divisions by a constant.
 

Macros

#define DEBUG_TYPE   "infer-address-spaces"
 

Functions

void llvm::initializeInferAddressSpacesPass (PassRegistry &)
 
 INITIALIZE_PASS (InferAddressSpaces, DEBUG_TYPE, "Infer address spaces", false, false) static bool isNoopPtrIntCastPair(const Operator *I2P
 
 if (!P2I||P2I->getOpcode() !=Instruction::PtrToInt) return false
 
return static CastInst::isNoopCast(Instruction::CastOps(I2P->getOpcode()), I2P->getOperand(0) ->getType(), I2P->getType(), DL) &&CastInst bool isAddressExpression (const Value &V, const DataLayout &DL, const TargetTransformInfo *TTI)
 
static SmallVector< Value *, 2 > getPointerOperands (const Value &V, const DataLayout &DL, const TargetTransformInfo *TTI)
 
static ValueoperandWithNewAddressSpaceOrCreateUndef (const Use &OperandUse, unsigned NewAddrSpace, const ValueToValueMapTy &ValueWithNewAddrSpace, SmallVectorImpl< const Use * > *UndefUsesToFix)
 
static ValuecloneConstantExprWithNewAddressSpace (ConstantExpr *CE, unsigned NewAddrSpace, const ValueToValueMapTy &ValueWithNewAddrSpace, const DataLayout *DL, const TargetTransformInfo *TTI)
 
static bool isSimplePointerUseValidToReplace (const TargetTransformInfo &TTI, Use &U, unsigned AddrSpace)
 returns true if U is the pointer operand of a memory instruction with a single pointer operand that can have its address space changed by simply mutating the use to a new value. More...
 
static bool handleMemIntrinsicPtrUse (MemIntrinsic *MI, Value *OldV, Value *NewV)
 Update memory intrinsic uses that require more complex processing than simple memory instructions. More...
 
static Value::use_iterator skipToNextUser (Value::use_iterator I, Value::use_iterator End)
 

Variables

static cl::opt< bool > AssumeDefaultIsFlatAddressSpace ("assume-default-is-flat-addrspace", cl::init(false), cl::ReallyHidden, cl::desc("The default address space is assumed as the flat address space. " "This is mainly for test purpose."))
 
static const unsigned UninitializedAddressSpace
 
const DataLayoutDL
 
const DataLayout const TargetTransformInfoTTI
 
auto * P2I = dyn_cast<Operator>(I2P->getOperand(0))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "infer-address-spaces"

Definition at line 134 of file InferAddressSpaces.cpp.

Function Documentation

◆ cloneConstantExprWithNewAddressSpace()

static Value* cloneConstantExprWithNewAddressSpace ( ConstantExpr CE,
unsigned  NewAddrSpace,
const ValueToValueMapTy ValueWithNewAddrSpace,
const DataLayout DL,
const TargetTransformInfo TTI 
)
static

◆ getPointerOperands()

static SmallVector<Value *, 2> getPointerOperands ( const Value V,
const DataLayout DL,
const TargetTransformInfo TTI 
)
static

◆ handleMemIntrinsicPtrUse()

static bool handleMemIntrinsicPtrUse ( MemIntrinsic MI,
Value OldV,
Value NewV 
)
static

Update memory intrinsic uses that require more complex processing than simple memory instructions.

Thse require re-mangling and may have multiple pointer operands.

Definition at line 936 of file InferAddressSpaces.cpp.

References assert(), B, llvm_unreachable, and MI.

◆ if()

if ( !P2I||P2I->getOpcode() !  = Instruction::PtrToInt)

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( InferAddressSpaces  ,
DEBUG_TYPE  ,
"Infer address spaces"  ,
false  ,
false   
) const

◆ isAddressExpression()

return static CastInst::isNoopCast (Instruction::CastOps(I2P->getOpcode()), I2P->getOperand(0)->getType(), I2P->getType(), DL) && CastInst bool isAddressExpression ( const Value V,
const DataLayout DL,
const TargetTransformInfo TTI 
) &&
static

◆ isSimplePointerUseValidToReplace()

static bool isSimplePointerUseValidToReplace ( const TargetTransformInfo TTI,
Use U,
unsigned  AddrSpace 
)
static

returns true if U is the pointer operand of a memory instruction with a single pointer operand that can have its address space changed by simply mutating the use to a new value.

If the memory instruction is volatile, return true only if the target allows the memory instruction to be volatile in the new address space.

Definition at line 906 of file InferAddressSpaces.cpp.

References llvm::Use::getOperandNo(), llvm::LoadInst::getPointerOperandIndex(), llvm::StoreInst::getPointerOperandIndex(), llvm::AtomicCmpXchgInst::getPointerOperandIndex(), llvm::AtomicRMWInst::getPointerOperandIndex(), llvm::Use::getUser(), llvm::TargetTransformInfo::hasVolatileVariant(), I, and SI.

◆ operandWithNewAddressSpaceOrCreateUndef()

static Value* operandWithNewAddressSpaceOrCreateUndef ( const Use OperandUse,
unsigned  NewAddrSpace,
const ValueToValueMapTy ValueWithNewAddrSpace,
SmallVectorImpl< const Use * > *  UndefUsesToFix 
)
static

◆ skipToNextUser()

static Value::use_iterator skipToNextUser ( Value::use_iterator  I,
Value::use_iterator  End 
)
static

Definition at line 1016 of file InferAddressSpaces.cpp.

Variable Documentation

◆ AssumeDefaultIsFlatAddressSpace

cl::opt<bool> AssumeDefaultIsFlatAddressSpace("assume-default-is-flat-addrspace", cl::init(false), cl::ReallyHidden, cl::desc("The default address space is assumed as the flat address space. " "This is mainly for test purpose."))
static

◆ DL

◆ P2I

auto* P2I = dyn_cast<Operator>(I2P->getOperand(0))

◆ TTI

Initial value:
{
assert(I2P->getOpcode() == Instruction::IntToPtr)

Definition at line 242 of file InferAddressSpaces.cpp.

◆ UninitializedAddressSpace

const unsigned UninitializedAddressSpace
static
Initial value:

Definition at line 143 of file InferAddressSpaces.cpp.

Referenced by isAddressExpression().

assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340