[llvm-commits] [RFC] Patch 1/3 for the native code compiler of Erlang

Yiannis Tsiouris gtsiour at softlab.ntua.gr
Tue Jun 26 13:18:56 PDT 2012


Hi Duncan and Anton,

On 06/26/2012 10:33 AM, Duncan Sands wrote:
>
>>  >>> F->getCallingConv() == CallingConv::HiPE : false);"
>>  >> What are exactly your concerns about it?
>>  >
>>  > it surely has to be wrong? I didn't look at the code in question, but it
>>  > sounds like at the point of a call you are looking at details of the callee.
>>  > But it should always be possible to codegen a call correctly just from the
>>  > declared type of the callee, the calling convention, the actual arguments and
>>  > any attributes they may have, without looking at the called function. That
>>  > said, I may have completely misunderstood what this is about - but it looks
>>  > like a big red flag.
>> Maybe I'm the one that misunderstood what you and Anton 're suggesting/concerned
>> about or misconceived the LLVM code, but i think that that is exactly what i do:
>> i use this "isHipeCall" condition to verify that it is a Hipe CC callee
> stop right there!  The calling convention of the callee doesn't matter when you
> are generating code for a call, only the calling convention of the call
> instruction matters.
>
> You are generating code for the call here, right?  And F is the callee?  If not,
> feel free to say: stop right there!
Duncan, you 're right for the one use of "isHipeCall" and wrong about
the other. More detaily:

- In "X86RI::getPointerRegClass()" F is the calleR and I want to check
the CC of the calleR in order to return the appropriate register class
for TC. "isHipeCall" is not a good name for this check; thus, i changed
it to "hasHipeCC" to better match the intended use! :-)

- In "X86ISL::GetAlignedArgumentStackSize()" I should check for the CC
of the call instruction, as you suggest. This function is called from
"X86ISL::LowerCall()" and "X86ISL::LowerFormalArguments()" only, where
there is available information of the CC of the call instruction. It's
rather trivial to pass this information as an extra argument to the
"X86ISL::GetAlignedArgumentStackSize()" (I attach a separate patch for
this; please commit if this looks good to you as i don't have commit
access).

On 06/26/2012 01:41 AM, Anton Korobeynikov wrote:
>>> >> It seems you require tail call optimizations on every call, right?
>>> >> What will be if the call will be via function pointer?
>> > Yes, HiPE CC should support tailcall optimization for every call. I
>> > don't quite understand what's the potential problem here... What do you
>> > mean a "call via function pointer"?
> The case when F is NULL here. Consider the following C code:
>
> void foo(void (*bar)(void)) {
>   bar();
> }
This should also be handled as a simple tailcall, shouldn't it? And
actually it's handled correctly in the HiPE LLVM backend.

I attatch a slightly modified patch that addresses Duncan's comments.

Yiannis

-- 
Yiannis Tsiouris
Ph.D. student,
Software Engineering Laboratory,
National Technical University of Athens
WWW: http://www.softlab.ntua.gr/~gtsiour

-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-callcc-to-getalignedargumentstacksize.patch
Type: text/x-diff
Size: 2417 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120626/29c9b58e/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hipe-calling-conv-v3.patch
Type: text/x-diff
Size: 11881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120626/29c9b58e/attachment-0001.patch>


More information about the llvm-commits mailing list