The X86 backend only needs to know whether structure return is via an sret pointer. This removes the categorization enumeration and adjusts and renames the related functions.
Details
- Reviewers
rnk - Commits
- rGc11e7b59d2e9: [X86][NFC] structure-return simplificiation
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
All three conditions that use this value are trying to determine if the callee is expected to pop the sret pointer off the stack. They have some duplicate subtarget checks that can probably be simplified. They all check these conditions:
- !IsMCU: MCU doesn't seem to pop the sret value ever
- !Is64Bit: In the TCO eligbility check, this is expressed as Is32bit, but is functionally identical
- !IsMSVC: MSVC doesn't do this callee-pop sret thing
- !IsInReg: sret parameters marked with inreg are not popped (reasonable)
So, can I suggest this simplification:
- replace the IsMCU parameter with the subtarget
- move all three subtarget checks into these functions. Consider sharing them, maybe a helper like isSRetCalleePop, it's basically Is32bit && !IsMSVC && !IsMCU.
- make the helper names more precise: returnHasCalleePopSRet / argsHaveCalleePopSRet
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
3352–3353 | There's a subtlety here: LLVM doesn't require that sret arguments come first. However, it would be impossible for the callee to pop off the second argument and leave behind the first, so this convention is only ever used when the sret argument appears first. Therefore only the first argument needs to be checked. | |
4665–4668 | This comment should live with the target checks if those get moved. |
thanks for your comments. Moving the check-which-ABI bits into the predicate does make things much simpler. I chose to templatize it, rather than write the same thing twice. That does mean taking a SmallVector<T> reference, rather than ArrayRef, because template deduction. But that ends up with less work to do anyway. I reordered the checks to get the best short-circuiting (heuristic guesswork though).
would you prefer anonymous namespace, or stick with the static fn?
lgtm, thanks!
LLVM has a guideline preferring static:
https://llvm.org/docs/CodingStandards.html#anonymous-namespaces
There's a subtlety here: LLVM doesn't require that sret arguments come first. However, it would be impossible for the callee to pop off the second argument and leave behind the first, so this convention is only ever used when the sret argument appears first. Therefore only the first argument needs to be checked.