EmbDev.net

Forum: ARM programming with GCC/GNU tools flatten function attribute


Author: Joe (Guest)
Posted on:

Rate this post
0 useful
not useful
Has anyone had success with __attribute__((flatten)) using yagarto?

I have tried various locations of the attribute tag in the function 
declaration or definition, but it appears the attribute is completely 
ignored.
void test_flatten(void) __attribute__((flatten));

void test_flatten(void){
    function1();
    function2();
}

From what I understand, flatten is supposed to "inline" all calls within 
a function, essentially creating one large "stand-alone" function.  When 
I step through the supposedly flattened code, there are still "bl" 
instructions to function1() and function2() locations.

Author: Joe Dupre (jdupre)
Posted on:

Rate this post
0 useful
not useful
I should add that the docs say "The flatten attribute only works 
reliably in unit-at-a-time mode. ", which should be enabled with 
optimization -O1. But I still get don't get the single monolithic block 
of code I expect, there are still branches to the other functions.

Author: Rolf Magnus (Guest)
Posted on:

Rate this post
0 useful
not useful
> From what I understand, flatten is supposed to "inline" all calls within
> a function

... "if possible". Did you define those two functions in the same 
implementation file as your test_flatten function? If they are 
implemented in a different one, they can't be inlined.

Author: Joe Dupre (jdupre)
Posted on:

Rate this post
0 useful
not useful
No.  One of the functions was in a different file.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.