[LLVMdev] Default/initial values for function arguments?
John Criswell
jtcriswel at gmail.com
Fri Aug 15 14:59:23 PDT 2014
Dear Cheng-Chih,
Can you clarify what you mean by ensuring that "%0 has a default value?"
Are you trying to ensure that the function's arguments have a default
value if the function is called with too few arguments?
The only way that %0 is going to have an undefined value is if a) a
function passes in an undefined value (like undef) or b) the function is
called with few two arguments. Unless you're trying to address behavior
that is undefined at the LLVM IR level, your question doesn't make much
sense.
Regards,
John Criswell
On 8/15/14, 4:54 PM, Cheng-Chih Yang wrote:
> 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
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list