[LLVMdev] A problem on returning value for functions

杨勇勇 triple.yang at gmail.com
Tue Jul 9 04:56:10 PDT 2013


Hi,

I write a backend and come cross an abnormal problem. Here I give a example
to describe it:

///////////////////////////////////////////////////////////////////////////////////////////
// A simple C function
int  foo()
{
  return 1234;
}
/////////////////////////////////////////////////////////////////////////////////////////

When compiling foo() into my target ISA, I would expect codes like:

/////////////////////////////////////////////////////////////////////////////////////////
...
movi  r0, #1234  // prepare r0 to return value 1234.
...
ret     // return to caller.
////////////////////////////////////////////////////////////////////////////////////////

The headache is when I pass option -O0 to llc, the generated codes are
correct. However, if I omit -O0 and use default compiling options, the
instruction "movi  r0, #1234" does not show.

I have already checked DAGs using options -view-xxxxx-dags and they all
seem OK.

I do not have any clue right now. Please help me.

Thank you.

-- 
杨勇勇 (Yang Yong-Yong)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130709/a42f9ee2/attachment.html>


More information about the llvm-dev mailing list