This patch refactors handling of VarArgs in
X86TargetLowering::LowerFormalArguments.
That refactoring was requested while reviewing
D69372. Code related to varargs handling is removed
from X86TargetLowering::LowerFormalArguments and
is divided into smaller routines.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Definitely a step in the right direction, thanks!
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
3333–3346 | this struct and VarArgsLoweringHelper::getVarArgRegsDescriptor seem unnecessary and are only used in the is64Bit() part, can all the variables be inlined? |
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
3333–3346 | @aeubanks Thank you, for the comment and Excuse me for a delayed answer. I missed a notification about that comment. This structure is used as a parameter for createVarArgAreaAndStoreRegisters() and later I am going to use it in forwardMustTailParameters(for D69372). If it would be inlined then both of these functions - createVarArgAreaAndStoreRegisters and forwardMustTailParameters will have duplicated code. So the reason of VarArgsLoweringHelper::getVarArgRegsDescriptor is to have single register description and avoid code duplication. Do you think it is still better to inline VarArgsLoweringHelper::getVarArgRegsDescriptor ? |
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
3333–3346 | But it looks like VarArgRegsDescr is only populated, and therefore only useful when is64Bit() is true. And the usage of RegDescr in createVarArgAreaAndStoreRegisters() seems to support that. Or do you mean you plan on extending getVarArgRegsDescriptor() later? Or using VarArgRegsDescr in non-64 bit contexts later? |
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
3333–3346 | I did not plan to use it in non-64 bit context(Though it could be done later if necessarily for some specific architecture). The idea was to create bits-neutral description(VarArgRegsDescr) once and use it later (in createVarArgAreaAndStoreRegisters and forwardMustTailParameters). If that is unnecessary general for that case - then I would inline that descriptor. |
Looks much better, just one small question.
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
3523–3524 | This isn't the exact same logic as before, is that intended? |
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
3523–3524 | Yes. I moved it intentionally. if (!Is64Bit) { // RegSaveFrameIndex is X86-64 only. FuncInfo->setRegSaveFrameIndex(0xAAAAAAA); if (CallConv == CallingConv::X86_FastCall || CallConv == CallingConv::X86_ThisCall) // fastcc functions can't have varargs. FuncInfo->setVarArgsFrameIndex(0xAAAAAAA); } Instead, I always set FrameIndex to an invalid value in the start. Thus if we forget to set that value, we will immediately see 0xAAAAAAA index. |
Ah 0xAAAAAAAA is supposed to be an invalid value, that's not immediately obvious. Maybe worth a comment?
this struct and VarArgsLoweringHelper::getVarArgRegsDescriptor seem unnecessary and are only used in the is64Bit() part, can all the variables be inlined?