Closed
Description
I hoped this would work
const fn get_3() -> u32
{
3
}
pub unsafe fn use_get_3()
{
asm!("" : : "i"(get_3()))
}
but it generates (without optimizations)
%0 = call i32 @_ZN8rust_out5get_317hccb90954bf88bf3cE()
call void asm "", "i,~{dirflag},~{fpsr},~{flags}"(i32 %0)
giving error: invalid operand for inline asm constraint 'i'
.
The current solution seems to be
pub unsafe fn use_three()
{
const THREE: u32 = get_3();
asm!("" : : "i"(THREE))
}
which generates
call void asm "", "i,~{dirflag},~{fpsr},~{flags}"(i32 3)
like I hoped the first case would.
Could we make the first case guaranteed to work?