-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cir] [Lowering] Handle VaArg #1088
base: main
Are you sure you want to change the base?
Conversation
Hey, thanks for making progress here.
If other targets use it and x86_64 doesn't, it means x86_64 is doing something special we probably want. If we go with the generic approach the motivations to match OG could wait forever, my take is that, if possible, we should target for de facto approach right away.
IMO the bad experience should force the consumers to implement the OG approach, the incentives to work on the OG-like solution will diminish if we provide a working (non-optimal) path.
I believe it's important to understand the differences first. Why OG x86_64 doesn't use va_arg? I'm assuming there's a good reason for this (sorry, I don't remember anymore). I propose that after #1086 and #1087 land, you create an issue explaining (a) why the status quo isn't robuts (as your mentioned in the previous paragraph), (b) whether/how that can be fixed and (c) re-evaluate whether we should just use va_arg in face of that and what are the steps to move away from it once someone is willing to do the work. The discussion in (c) should help us decide if we should use va_arg for x86_64. How does this sound? |
Sounds good to me. And I'd like to write something down here when I have the context : )
Yeah, understanding the underlying problem is great. And I searched https://discourse.llvm.org/t/rfc-the-future-of-the-va-arg-instruction/45908 it mentions:
While these things,
To make this robust, we need a full X86_64 type classification. And also we need to be able to generate different vector types. And I also want to mark that, |
Thanks for pointing me to that discussion again :)
This kinda confirms that we are probably better off not using
My understanding is that this can be done without any fundamental problem in CIR -> CIR, given we add all the bits. Trying to summarize the discussion: are you saying that we should use |
Yes in the end of the day. And in fact, the design of clangir allows us to get rid of va_arg completely. As it is mentioned in the above thread:
Frontend are too early and SelectionDAG are too late then clangir looks in the proper position : )
Yes. And I feel |
This is the following of #1100. After #1100, when we want to use LongDouble for VAArg, we will be in trouble due to details in X86_64's ABI and this patch tries to address this. The practical impact the patch is, after this patch, with #1088 and a small following up fix, we can build and run all C's benchmark in SpecCPU 2017. I think it is a milestone.
I tried to reopen #865 but github get stucked..
After one month's deep experience with this patch, now I am more confident we need this patch.
For the long term, in the end of the day, we will need this since
va_arg
instruction is used in other targets in the traditional CodeGen pipeline. And in fact, theva_arg
instruction lowering the default one in the traditional CG pipeline.For the short term, this is still needed given we have non-robust X86 arguments classification today (See #1087). VAArg is pretty common in C codes. Without this, people who want to try clangir in the early days will meet the failures, this is pretty a bad experience.
For the maintaining concerns, since now we have #1086, we can add support more types after we make X86's arguments classification more stable. Like we did in #1087.
And it shows the code generated with
va_arg
is pretty good and LLVM will emit the error immediately if the LLVM can't handle it well.