Re: Jumps across functions
- From: dj3vande@xxxxxxxxxxxxxxxxxxx (Dave Vandervies)
- Date: Mon, 27 Aug 2007 22:50:23 +0000 (UTC)
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
.
- Follow-Ups:
- Re: Jumps across functions
- From: Gene
- Re: Jumps across functions
- References:
- Jumps across functions
- From: Tim Frink
- Jumps across functions
- Prev by Date: Jumps across functions
- Next by Date: Re: Jumps across functions
- Previous by thread: Jumps across functions
- Next by thread: Re: Jumps across functions
- Index(es):
Relevant Pages
|