[LLVMdev] Default/initial values for function arguments?

Cheng-Chih Yang cheng-chih.yang at amd.com
Fri Aug 15 13:54:15 PDT 2014


Hi guys,

I’m trying to figure out a way to assign initial values to function arguments. For a function in IR:

define i32 @main (i32 %0, i32 %1)
{
	%tmp = add i32 %0, %1
	...
}

I would like to make sure %0 has some initial value (e.g. i32 0) under some circumstances. Is there any easy way to do this? I understand that %0 comes from a live-in value which is defined from outside of the function. I could,  at the ISelLowering stage when seeing an ADD, replace the “%0” with a i32 constant 0, but I don’t feel like this is the right approach.

Should I try to look into SUBREG_TO_REG/INSERT_REG here? Or any other thoughts? 

Thanks,
- Cheng-Chih





More information about the llvm-dev mailing list