Lines Matching +full:ri +full:- +full:override
1 //===- AMDGPURewriteOutArgumentsPass.cpp - Create struct returns ----------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
42 //===----------------------------------------------------------------------===//
57 #define DEBUG_TYPE "amdgpu-rewrite-out-arguments"
62 "amdgpu-any-address-space-out-arguments",
64 "struct returns for non-private address space"),
69 "amdgpu-max-return-arg-num-regs",
94 void getAnalysisUsage(AnalysisUsage &AU) const override { in getAnalysisUsage()
99 bool doInitialization(Module &M) override;
100 bool runOnFunction(Function &F) override;
125 if (auto *BCI = dyn_cast<BitCastInst>(U->getUser())) { in getStoredType()
126 for (Use &U : BCI->uses()) in getStoredType()
131 if (auto *SI = dyn_cast<StoreInst>(U->getUser())) { in getStoredType()
135 if (!SI->isSimple() || in getStoredType()
136 U->getOperandNo() != StoreInst::getPointerOperandIndex()) in getStoredType()
139 if (StoredType && StoredType != SI->getValueOperand()->getType()) in getStoredType()
141 StoredType = SI->getValueOperand()->getType(); in getStoredType()
157 if (!ArgTy || (ArgTy->getAddressSpace() != DL->getAllocaAddrSpace() && in getOutArgumentType()
164 if (!StoredType || DL->getTypeStoreSize(StoredType) > MaxOutArgSizeBytes) in getOutArgumentType()
190 if (!RetTy->isVoidTy()) { in runOnFunction()
191 ReturnNumRegs = DL->getTypeStoreSize(RetTy) / 4; in runOnFunction()
217 if (ReturnInst *RI = dyn_cast<ReturnInst>(&BB.back())) in runOnFunction() local
218 Returns.push_back(RI); in runOnFunction()
248 unsigned ArgNumRegs = DL->getTypeStoreSize(ArgTy) / 4; in runOnFunction()
254 for (ReturnInst *RI : Returns) { in runOnFunction()
255 BasicBlock *BB = RI->getParent(); in runOnFunction()
257 MemDepResult Q = MDA->getPointerDependencyFrom( in runOnFunction()
258 MemoryLocation::getBeforeOrAfter(OutArg), true, BB->end(), BB, RI); in runOnFunction()
265 ReplaceableStores.emplace_back(RI, SI); in runOnFunction()
276 Value *ReplVal = Store.second->getValueOperand(); in runOnFunction()
292 Store.second->eraseFromParent(); in runOnFunction()
297 OutArgIndexes.insert({OutArg->getArgNo(), ArgTy}); in runOnFunction()
307 LLVMContext &Ctx = F.getParent()->getContext(); in runOnFunction()
311 F.getFunctionType()->params(), in runOnFunction()
318 F.getParent()->getFunctionList().insert(F.getIterator(), NewFunc); in runOnFunction()
319 NewFunc->copyAttributesFrom(&F); in runOnFunction()
320 NewFunc->setComdat(F.getComdat()); in runOnFunction()
324 NewFunc->stealArgumentListFrom(F); in runOnFunction()
330 NewFunc->removeRetAttrs(RetAttrs); in runOnFunction()
333 NewFunc->setIsNewDbgInfoFormat(F.IsNewDbgInfoFormat); in runOnFunction()
337 NewFunc->splice(NewFunc->begin(), &F); in runOnFunction()
340 ReturnInst *RI = Replacement.first; in runOnFunction() local
341 IRBuilder<> B(RI); in runOnFunction()
342 B.SetCurrentDebugLocation(RI->getDebugLoc()); in runOnFunction()
347 Value *RetVal = RI->getReturnValue(); in runOnFunction()
355 RI->setOperand(0, NewRetVal); in runOnFunction()
358 RI->eraseFromParent(); in runOnFunction()
377 int RetIdx = RetTy->isVoidTy() ? 0 : 1; in runOnFunction()
384 DL->getValueOrABITypeAlignment(Arg.getParamAlign(), EltTy); in runOnFunction()
390 if (!RetTy->isVoidTy()) { in runOnFunction()