[cfe-dev] Figuring out if parameter types are passed in same register

mats petersson via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 14 02:59:12 PDT 2015

I'm assuming you are looking to "not reload edi", but that's not going to
work if f1 or f2 makes any call that takes an argument [or edi is used for
something else in the function!].


void f1(long x)

which would lead to

    mov  edi, 42
    call    _f3;

so now edi is not the same any longer.

If you can inline the code (and f1 doesn't make any calls or use edi for
any other purpose), then the optimiser will remove the second load anyway.

Note that perhaps you are confusing the 32-bit calling convention where edi
is a callee preserved register - but then it's also not used to pass
arguments either.


On 14 September 2015 at 09:49, Nat! via cfe-dev <cfe-dev at lists.llvm.org>

> Assuming you use a x86_64, when you compile
> extern void   f1( long x);
> extern void   f2( void *x);
> void   g( void)
> {
>    f1( 1848);
>    f2( (void *) 1848);
> }
> it compiles into identical argument passing code
>    mov  edi, 1848
>    call _f1
>    mov  edi, 1848
>    call _f2
> This would not happen on a 680x0, because integers are passed in Dx
> registers and pointers in Ax registers (if I remember correctly).
> Is there a way to figure out, given two types, if they are both passed
> using the same register ? [^1]
> Ciao
>    Nat!
> [^1] It's given, that all preceeding argument types are known and same.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150914/1002f603/attachment.html>

More information about the cfe-dev mailing list