<div dir="ltr"><div>Traditional *nix linkers and object file formats do not carry any type information for functions, only the address of the entry point.</div><div><br></div>It works because when arguments are passed in registers (as they are for x86_64), everything is passed as the register size (here 64 bit), no matter what size you declared it.<div><br></div><div>It can also work on machines that pass arguments on the stack, because often there is an alignment requirement on the stack pointer. However, that is more likely to work between i8/i16/i32 than between those and i64. (it depends on the machine)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 11, 2015 at 9:39 PM, Ksenia Dolgorukova <span dir="ltr"><<a href="mailto:der.spiegel.sieht.mich@gmail.com" target="_blank">der.spiegel.sieht.mich@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">They both was compiled with clang for 64-bit target. These example<br>
bitcode files was modified by hand to check if this case will work.<br>
Actually, this feature was revealed when I compiled 'coremark'<br>
benchmark with LTO for x68-64 target. I think, different signatures<br>
was caused by preprocessor directives.<br>
But I wander how can it work.<br>
<div class="HOEnZb"><div class="h5"><br>
2015-04-10 21:05 GMT+03:00 Nick Lewycky <<a href="mailto:nicholas@mxc.ca">nicholas@mxc.ca</a>>:<br>
> Ksenia Dolgorukova wrote:<br>
>><br>
>> Hello!<br>
>> I linked two bitcode files like described below using LTO and find<br>
>> they are linked fine instead of making an error.<br>
>> ----------<br>
>> 1.bc<br>
>> ----------<br>
>> ...<br>
>> define i32 @main(i32 %argc, i8** %argv) #0 {<br>
>> entry:<br>
>> ...<br>
>> %call = call i32 @_Z1aj(i64 2)<br>
>> ...<br>
>> }<br>
>> declare i32 @_Z1aj(i64) #1<br>
>> ...<br>
>><br>
>> ----------<br>
>> 2.bc<br>
>> ----------<br>
>> ...<br>
>> define i32 @_Z1aj(i32 %b) #0 {<br>
>> entry:<br>
>> ...<br>
>> }<br>
>> ...<br>
>><br>
>> ----------<br>
>><br>
>> In the first file function "_Z1aj" is declared as having i64 argument,<br>
>> whereas in the second file the function "_Z1aj" is described as having<br>
>> i32 argument!<br>
>><br>
>> Are function signatures different?<br>
><br>
><br>
> They're both 'a(unsigned int)', but perhaps you compiled one of them<br>
> targeting a 32-bit platform and the other targeting a 64-bit platform? What<br>
> triple is at the top of each .bc file?<br>
><br>
><br>
>> How does LLVM cast them?<br>
>> Could it be a bug?<br>
>><br>
><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Best regards, Ksenia<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>