[LLVMdev] Structs as first class values.
Richard Pennington
rich at pennware.com
Mon Jul 21 14:38:35 PDT 2008
Matthijs Kooijman wrote:
> On this topic, you should look at the StructRetPromotion pass
> (lib/Transforms/IPO/StructRetPromotion.cpp). This pass does exactly the
> opposite of what you propose: It transforms return pointers in the first
> parameter to first class returns.
>
> This pass only operates on internal functions, though, so it does not have to
> deal with ABI issues. If you want to support the C ABI (which requires a
> pointer in the first argument to return any struct AFAIK), you might be better
> off generating such code in your frontend. Any internal function can then be
> simplified by the sretpromotion pass (perhaps it could be modified to take an
> option for the maximum number of elements to put in the real return struct?)
Hi Matthijs,
Thanks for the pointer. It was the first time I looked at an LLVM pass
closely. Very nice and simple!
I think I will have my frontend pass the pointer. I can always back it
out when return values are handled. Although it might be fun to try to
implement a StructRetDemotion pass. ;-)
-Rich
More information about the llvm-dev
mailing list