32#define DEBUG_TYPE "nvptx"
57 if (
SI->getOperand(0) != LI)
75 if (AggrLoads.
size() == 0 && MemCalls.
size() == 0) {
84 Value *SrcAddr = LI->getOperand(0);
85 Value *DstAddr =
SI->getOperand(1);
86 unsigned NumLoads =
DL.getTypeStoreSize(LI->getType());
115 unsigned SrcAS = LI->getPointerAddressSpace();
116 unsigned DstAS =
SI->getPointerAddressSpace();
117 if (SrcAS != DstAS) {
120 SrcAddr = Builder.CreateAddrSpaceCast(SrcAddr, GenericPtrTy);
121 DstAddr = Builder.CreateAddrSpaceCast(DstAddr, GenericPtrTy);
124 DstAddr,
SI->getAlign(), SrcAddr, LI->getAlign(), CopyLen,
125 LI->isVolatile() ||
SI->isVolatile())));
128 SI->eraseFromParent();
129 LI->eraseFromParent();
134 bool Expanded =
true;
143 MemCall->eraseFromParent();
151struct NVPTXLowerAggrCopiesLegacyPass :
public FunctionPass {
154 NVPTXLowerAggrCopiesLegacyPass() : FunctionPass(ID) {}
156 void getAnalysisUsage(AnalysisUsage &AU)
const override {
164 F, getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
F),
165 getAnalysis<AAResultsWrapperPass>().getAAResults());
168 StringRef getPassName()
const override {
169 return "Lower aggregate copies/intrinsics into loops";
173char NVPTXLowerAggrCopiesLegacyPass::ID = 0;
178 NVPTXLowerAggrCopiesLegacyPass,
"nvptx-lower-aggr-copies",
179 "Lower aggregate copies, and llvm.mem* intrinsics into loops",
false,
false)
183 NVPTXLowerAggrCopiesLegacyPass,
"nvptx-lower-aggr-copies",
184 "Lower aggregate copies, and llvm.mem* intrinsics into loops",
false,
false)
187 return new NVPTXLowerAggrCopiesLegacyPass();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool runOnFunction(Function &F, bool PostInlining)
Module.h This file contains the declarations for the Module class.
static bool lowerAggrCopies(Function &F, const TargetTransformInfo &TTI, AAResults &AA)
static const unsigned MaxAggrCopySize
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
A manager for alias analyses.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM Basic Block Representation.
This is the shared class of boolean and integer constants.
A parsed version of the target data layout string in and methods for querying it.
FunctionPass class - This class is used to implement most global optimizations.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
static LocationSize precise(uint64_t Value)
This class wraps the llvm.memcpy intrinsic.
This is the common base class for memset/memcpy/memmove.
This class wraps the llvm.memmove intrinsic.
This class wraps the llvm.memset and llvm.memset.inline intrinsics.
Representation for a specific memory location.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
static LLVM_ABI PointerType * get(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserve()
Mark an analysis as preserved.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Analysis pass providing the TargetTransformInfo.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
Abstract Attribute helper functions.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void createMemCpyLoopKnownSize(Instruction *InsertBefore, Value *SrcAddr, Value *DstAddr, ConstantInt *CopyLen, Align SrcAlign, Align DestAlign, bool SrcIsVolatile, bool DstIsVolatile, bool CanOverlap, const TargetTransformInfo &TTI, std::optional< uint32_t > AtomicCpySize=std::nullopt, std::optional< uint64_t > AverageTripCount=std::nullopt)
Emit a loop implementing the semantics of an llvm.memcpy whose size is a compile time constant.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool expandMemMoveAsLoop(MemMoveInst *MemMove, const TargetTransformInfo &TTI)
Expand MemMove as a loop.
FunctionPass * createNVPTXLowerAggrCopiesLegacyPass()
LLVM_ABI void expandMemSetAsLoop(MemSetInst *MemSet, const TargetTransformInfo *TTI=nullptr)
Expand MemSet as a loop.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI, ScalarEvolution *SE=nullptr)
Expand MemCpy as a loop. MemCpy is not deleted.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.