[llvm-dev] Passing arguments and returning value of struct or class

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Passing arguments and returning value of struct or class

Alberto Barbaro via llvm-dev
Hi all.

I'm new to LLVM and I'm having fun with LLVM.
Recently, I fount that function calls are changed based on the types of return value and arguments.

For example, as following codes, the generated LLVM IRs are efferent from what I expected them would be.
-------------------
// simple C code
struct Float2
{
    float x; float y;
}
Float2 foo(Float2 a)
------------------- 
// simple LLVM IR
i64 foo(i64 a)
------------------------

Even, if the size of structure is bigger than 64bit, the LLVM IRs are as follow.
------------------------ 
void  foo( struct. Float2* ,  struct.Float2 * )  
------------------------ 

So. I wonder where can I find these rules? I googled but I could not found official documents or something likes that.

Please help me.

Thanks.
Chanhyun.

 



_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Passing arguments and returning value of struct or class

Alberto Barbaro via llvm-dev
I remember as pointed out by someone else on the mailing list. (Tim, I believe) This is Clang trying to match the platform’s ABI specification

Zhang

> 在 2018年12月5日,03:59,Chanhyun Park via llvm-dev <[hidden email]> 写道:
>
> Hi all.
>
> I'm new to LLVM and I'm having fun with LLVM.
> Recently, I fount that function calls are changed based on the types of return value and arguments.
>
> For example, as following codes, the generated LLVM IRs are efferent from what I expected them would be.
> -------------------
> // simple C code
> struct Float2
> {
>     float x; float y;
> }
> Float2 foo(Float2 a)
> -------------------
> // simple LLVM IR
> i64 foo(i64 a)
> ------------------------
>
> Even, if the size of structure is bigger than 64bit, the LLVM IRs are as follow.
> ------------------------
> void  foo( struct. Float2* ,  struct.Float2 * )  
> ------------------------
>
> So. I wonder where can I find these rules? I googled but I could not found official documents or something likes that.
>
> Please help me.
>
> Thanks.
> Chanhyun.
>
>  
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Passing arguments and returning value of struct or class

Alberto Barbaro via llvm-dev
In reply to this post by Alberto Barbaro via llvm-dev
Hello

These rules are called "platform ABI". So, clang is emitting the IR to
match the requirements the ABI of a particular platform.

See e.g. 3.2.3 of
https://software.intel.com/sites/default/files/article/402129/mpx-linux64-abi.pdf
for an example of such rules on x86-64 platform (they are different on
other platforms).
On Wed, Dec 5, 2018 at 3:59 AM Chanhyun Park via llvm-dev
<[hidden email]> wrote:

>
> Hi all.
>
> I'm new to LLVM and I'm having fun with LLVM.
> Recently, I fount that function calls are changed based on the types of return value and arguments.
>
> For example, as following codes, the generated LLVM IRs are efferent from what I expected them would be.
> -------------------
> // simple C code
> struct Float2
> {
>     float x; float y;
> }
> Float2 foo(Float2 a)
> -------------------
> // simple LLVM IR
> i64 foo(i64 a)
> ------------------------
>
> Even, if the size of structure is bigger than 64bit, the LLVM IRs are as follow.
> ------------------------
> void  foo( struct. Float2* ,  struct.Float2 * )
> ------------------------
>
> So. I wonder where can I find these rules? I googled but I could not found official documents or something likes that.
>
> Please help me.
>
> Thanks.
> Chanhyun.
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



--
With best regards, Anton Korobeynikov
Department of Statistical Modelling, Saint Petersburg State University
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev