[llvm] [NVPTX] add an optional early copy of byval arguments (PR #113384)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 23 14:17:41 PDT 2024
================
@@ -734,3 +739,21 @@ bool NVPTXLowerArgs::runOnFunction(Function &F) {
}
FunctionPass *llvm::createNVPTXLowerArgsPass() { return new NVPTXLowerArgs(); }
+
+static bool copyFunctionByValArgs(Function &F) {
+ LLVM_DEBUG(dbgs() << "Creating a copy of byval args of " << F.getName()
+ << "\n");
+ bool Changed = false;
+ for (Argument &Arg : F.args())
+ if (Arg.getType()->isPointerTy() && Arg.hasByValAttr()) {
+ copyByValParam(F, Arg);
----------------
Artem-B wrote:
In a nutshell - yes. complete optimization pipeline works better than the last-ditch naive pointer use analysis + SROA pass to attempt removing the copies we made because our analysis was too simplistic.
When enabled, *all* byvals will have a copy added early. The assumption is that LLVM optimization passes will be able to remove those allocas, if possible (and that would cover the legal no-copy use cases for byval arguments), Remaining allocase are the ones that are really needed, and will not trigger additional argument copies, as copying to the alloca is done with loads only.
https://github.com/llvm/llvm-project/pull/113384
More information about the llvm-commits
mailing list