[llvm-commits] PATCH: llvm-gcc option to emit "va_arg" instruction
Dan Gohman
gohman at apple.com
Tue Oct 12 11:42:58 PDT 2010
On Oct 12, 2010, at 9:09 AM, David Meyer wrote:
> Rafael,
>
> This could be implemented at a higher level.
>
> Rewriting the va_arg instruction at the bitcode level would be the most powerful method, especially if you could apply opt to the target-specific bitcode after the rewrite.
One downside of this approach is that it would hamper a
fashionable optimization -- omitting the xmm-save code in
the x86-64 prologue if no xmm arguments are needed.
> Another way would be to emit a custom va_arg implementation as the initial SelectionDAG is being built. This would not be subject to opt, but it would be subject to better optimization in the backend.
This sounds like a good approach. For comparison, calls, return
values, and regular arguments are also lowered in the initial
SelectionDAG. See the LowerCall, LowerReturn, and
LowerFormalArguments hooks.
Your x86-64 va_arg implementation could still be used, since
x86-64's va_arg uses branching, and the SelectionDAG framework
doesn't support branches. On x86-64 the initial lowering
could just create a VAARG_64. Targets which don't need
branching could instead do the lowering immediately, and
benefit from having it be exposed to optimizations.
Dan
More information about the llvm-commits
mailing list