[llvm] [NVPTX][NFC] Refactoring and cleanup in NVPTXISelLowering (PR #137222)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 24 15:48:11 PDT 2025
================
@@ -3388,75 +3373,91 @@ SDValue NVPTXTargetLowering::LowerFormalArguments(
// individually present in Ins.
// So a different index should be used for indexing into Ins.
// See similar issue in LowerCall.
- unsigned InsIdx = 0;
+ const auto *In = Ins.begin();
+ auto ConsumeArgIns = [&](const Argument &Arg) {
+ const auto *ArgInsBegin = In;
+ const auto *ArgInsEnd = In;
+ while (ArgInsEnd != Ins.end() && ArgInsEnd->OrigArgIndex == Arg.getArgNo())
+ ++ArgInsEnd;
+ In = ArgInsEnd;
+ return llvm::ArrayRef(ArgInsBegin, ArgInsEnd);
+ };
----------------
Artem-B wrote:
Would this work?
```
ArrayRef taken = ArrayRef(In).take_while([](auto x){ return x->OrigArgIndex == Arg.getArgNo()});
In += taken.size();
return taken;
```
API wise, I think we may consider taking an input ArrayRef of elements to process, and returning two ArrayRefs -- one to the elements we've selected, and the remaining for the leftover elements to pass in on the next iteration. Might be an overkill, though. I'm just not fond of modifying external state from lambdas.
https://github.com/llvm/llvm-project/pull/137222
More information about the llvm-commits
mailing list