[LLVMdev] promotion of return value.
Rafael Espindola
espindola at google.com
Fri Mar 13 02:07:25 PDT 2009
2009/3/12 <Alireza.Moshtaghi at microchip.com>:
> What I was planning to do is to provide a default behavior that is
> consistent with what currently llvm does (promote to 32 bit)
> And then there will be control in clang for targets to do things
> differently.
> But I also understand you concern about gcc frontend; because the same
> thing has to also take place there....
> We had long discussions about this last year, and this is what has been
> decided. Maybe Chris is in a better position to decide what to do.
Can you take a look at my last post on the bug and see if that could work
for all the cases you have? Since llvm-gcc and clang are the ones doing
the lowering, i think it would. Consider the code
----------------------
short x;
void g(int);
short h(void);
short f(void) {
g(h());
return x;
}
--------------------
For X86, I think llvm IL for f can be
------------------------------------------
define i16 @f() nounwind {
entry:
%0 = tail call i16 @h() nounwind
%1 = sext i16 %0 to i32
tail call void @g(i32 %1) nounwind
%2 = load i16* @x, align 2
ret i16 %2
}
--------------------------------------
and for arm it can be
----------------------------------------
define i32 @f() nounwind {
entry:
%0 = tail call i32 @h() nounwind
tail call void @g(i32 %0) nounwind
%2 = load i16* @x, align 2
%3 = sext i16 %2 to i32
ret i32 %3
}
--------------------------------------
Note that for X86 only the caller does extension. For ARM only the
callee does it.
> A.
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
More information about the llvm-dev
mailing list