Re: Jumps across functions



In article <5jh0qcF3rrohsU2@xxxxxxxxxxxxxxxxxx>,
Tim Frink <plfriko@xxxxxxxx> wrote:
Hi,

is is possible to get valid assembler code from a
C source code with jumps from one routine
to a basic block in another routine?

Example:

routine main
.L1 ... // Labels for basic blocks
.L2 ...

routine foo
.L3
.L4

Can I have a jump from basic block L1 to basic block
L3?

The compiler can do anything it wants, as long as correct input results
in generated code that behaves appropriately.

One example of where a realistic compiler might actually do this is
"inlining" a tail-call:
Input code of this form:
--------
int foo(void)
{
/*do foo here*/
return result;
}

int main(void)
{
/*do setup here*/
if(success)
return foo();
else
return EXIT_FAILURE;
}
--------
could produce output of this form:
--------
routine foo
..L1
; do foo here
ret

routine main
;do setup here
jnz L1 ;tail-call to foo() if successfully initialized
;load failure return status here
ret
--------


dave

--
Dave Vandervies dj3vande@xxxxxxxxxxxxxxxxxxx
Because we're morally and physically superior to other people. When the
great energy crunch comes, we'll be the only people who can get around and
people will look to us for leadership. --Andy Gee in rec.bicycles.misc
.



Relevant Pages

  • Re: Jumps across functions
    ... C source code with jumps from one routine ... to a basic block in another routine? ... The compiler can do anything it wants, as long as correct input results ... // yada yada yada ...
    (comp.programming)
  • Re: Jumps across functions
    ... C source code with jumps from one routine ... Can I have a jump from basic block L1 to basic block ...
    (comp.programming)
  • Jumps across functions
    ... C source code with jumps from one routine ... Can I have a jump from basic block L1 to basic block ...
    (comp.programming)
  • Re: ooRexx construct similar to JavaScripts "this" in a HTML page
    ... You would define a public routine, ... use arg id ... ::routine foo public ...
    (comp.lang.rexx)
  • Code Jumps
    ... I have a wb with many UDFs and sheets, modules, forms etc. ... jumps to the following statement of the routine but to some statement of ... I'ld like to know if this is a correct behaviour or it's a sign ... Apart these jumps that I see only debugging, ...
    (microsoft.public.excel.programming)