LLVM 20.0.0git
|
#include "llvm/Transforms/Scalar/InferAddressSpaces.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Dominators.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/InitializePasses.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>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "infer-address-spaces" |
Functions | |
INITIALIZE_PASS_BEGIN (InferAddressSpaces, DEBUG_TYPE, "Infer address spaces", false, false) INITIALIZE_PASS_END(InferAddressSpaces | |
Infer address static false Type * | getPtrOrVecOfPtrsWithNewAS (Type *Ty, unsigned NewAddrSpace) |
static bool | isNoopPtrIntCastPair (const Operator *I2P, const DataLayout &DL, const TargetTransformInfo *TTI) |
static 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 Value * | operandWithNewAddressSpaceOrCreatePoison (const Use &OperandUse, unsigned NewAddrSpace, const ValueToValueMapTy &ValueWithNewAddrSpace, const PredicatedAddrSpaceMapTy &PredicatedAS, SmallVectorImpl< const Use * > *PoisonUsesToFix) |
static Value * | cloneConstantExprWithNewAddressSpace (ConstantExpr *CE, unsigned NewAddrSpace, const ValueToValueMapTy &ValueWithNewAddrSpace, const DataLayout *DL, const TargetTransformInfo *TTI) |
static bool | replaceOperandIfSame (Instruction *Inst, unsigned OpIdx, Value *OldVal, Value *NewVal) |
Replace operand OpIdx in Inst , if the value is the same as OldVal with NewVal . | |
template<typename InstrType > | |
static bool | replaceSimplePointerUse (const TargetTransformInfo &TTI, InstrType *MemInstr, unsigned AddrSpace, Value *OldV, Value *NewV) |
static bool | replaceIfSimplePointerUse (const TargetTransformInfo &TTI, User *Inst, unsigned AddrSpace, Value *OldV, Value *NewV) |
If OldV is used as the pointer operand of a compatible memory operation Inst , replaces the pointer operand with NewV. | |
static bool | handleMemIntrinsicPtrUse (MemIntrinsic *MI, Value *OldV, Value *NewV) |
Update memory intrinsic uses that require more complex processing than simple memory instructions. | |
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 |
DEBUG_TYPE | |
Infer address | spaces |
Infer address | false |
#define DEBUG_TYPE "infer-address-spaces" |
Definition at line 136 of file InferAddressSpaces.cpp.
|
static |
Definition at line 730 of file InferAddressSpaces.cpp.
References assert(), cloneConstantExprWithNewAddressSpace(), DL, llvm::ConstantExpr::getAddrSpaceCast(), llvm::ConstantExpr::getBitCast(), getPtrOrVecOfPtrsWithNewAS(), isNoopPtrIntCastPair(), llvm::ValueMap< KeyT, ValueT, Config >::lookup(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by cloneConstantExprWithNewAddressSpace().
|
static |
Definition at line 343 of file InferAddressSpaces.cpp.
References assert(), DL, II, isNoopPtrIntCastPair(), and llvm_unreachable.
|
static |
Definition at line 268 of file InferAddressSpaces.cpp.
References assert().
Referenced by cloneConstantExprWithNewAddressSpace(), and operandWithNewAddressSpaceOrCreatePoison().
|
static |
Update memory intrinsic uses that require more complex processing than simple memory instructions.
These require re-mangling and may have multiple pointer operands.
Definition at line 1085 of file InferAddressSpaces.cpp.
References assert(), B, llvm_unreachable, and MI.
INITIALIZE_PASS_BEGIN | ( | InferAddressSpaces | , |
DEBUG_TYPE | , | ||
"Infer address spaces" | , | ||
false | , | ||
false | |||
) |
|
static |
Definition at line 311 of file InferAddressSpaces.cpp.
References assert(), DL, llvm::TargetTransformInfo::getAssumedAddrSpace(), II, isNoopPtrIntCastPair(), and UninitializedAddressSpace.
|
static |
Definition at line 277 of file InferAddressSpaces.cpp.
References assert(), DL, llvm::Operator::getOpcode(), llvm::User::getOperand(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), llvm::TargetTransformInfo::isNoopAddrSpaceCast(), and llvm::CastInst::isNoopCast().
Referenced by cloneConstantExprWithNewAddressSpace(), getPointerOperands(), and isAddressExpression().
|
static |
Definition at line 585 of file InferAddressSpaces.cpp.
References llvm::CallingConv::C, llvm::Use::get(), llvm::PoisonValue::get(), llvm::ConstantExpr::getAddrSpaceCast(), llvm::Instruction::getDebugLoc(), getPtrOrVecOfPtrsWithNewAS(), llvm::Value::getType(), llvm::Use::getUser(), I, llvm::ValueMap< KeyT, ValueT, Config >::lookup(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
|
static |
If OldV
is used as the pointer operand of a compatible memory operation Inst
, replaces the pointer operand with NewV.
This covers memory instructions with a single pointer operand that can have its address space changed by simply mutating the use to a new value.
returns
true the user replacement was made.
Definition at line 1064 of file InferAddressSpaces.cpp.
References replaceSimplePointerUse().
|
static |
Replace operand OpIdx
in Inst
, if the value is the same as OldVal
with NewVal
.
Definition at line 1034 of file InferAddressSpaces.cpp.
References llvm::User::getOperandUse().
Referenced by replaceSimplePointerUse().
|
static |
Definition at line 1046 of file InferAddressSpaces.cpp.
References llvm::TargetTransformInfo::hasVolatileVariant(), and replaceOperandIfSame().
Referenced by replaceIfSimplePointerUse().
|
static |
Definition at line 1165 of file InferAddressSpaces.cpp.
|
static |
DEBUG_TYPE |
Definition at line 265 of file InferAddressSpaces.cpp.
Infer address false |
Definition at line 266 of file InferAddressSpaces.cpp.
Infer address spaces |
Definition at line 265 of file InferAddressSpaces.cpp.
Definition at line 145 of file InferAddressSpaces.cpp.
Referenced by isAddressExpression().