Chanhyun Park via llvm-dev
2018-Dec-05 03:59 UTC
[llvm-dev] Passing arguments and returning value of struct or class
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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181205/8a668c12/attachment.html>
mayuyu.io via llvm-dev
2018-Dec-05 05:06 UTC
[llvm-dev] Passing arguments and returning value of struct or class
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 <llvm-dev at lists.llvm.org> 写道: > > 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 > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Anton Korobeynikov via llvm-dev
2018-Dec-05 09:30 UTC
[llvm-dev] Passing arguments and returning value of struct or class
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 <llvm-dev at lists.llvm.org> 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 > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- With best regards, Anton Korobeynikov Department of Statistical Modelling, Saint Petersburg State University