- CapnBry
- Jul 15, 2002
-
I got this goin'
-
Grimey Drawer
|
I've got a gcc-avr question I was hoping to get some light shed on. Imagine this code:
code:// class.h
class Foo
{
private:
int _x;
int _y;
public:
void Bar(void);
void Baz(void);
};
// class.cpp
void Foo::Bar(void)
{
++_x;
Baz();
}
void Foo::Baz(void)
{
_y = 0;
}
// main.cpp
int main(void)
{
Foo A;
A.Bar();
A.Baz();
return 0;
}
avr-gcc 4.3.2 is inlining Baz() into Bar() and also inlining Baz() into main(). Normally I'd be all woohoo and poo poo about that but in my case Baz is 144 bytes of code and I'm really concerned about the code size here. I can flag Baz() the method with __attribute((noinline))__ for this instance, but in a 5,000 line program I'd like the compiler to decide to only inline functions when it makes the program smaller. I thought gcc wouldn't inline across module boundaries unless you used link-time optimization (-flto).
Command line
Compile: avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p ...
Link: avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p ...
|
#
¿
Sep 17, 2012 19:55
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 3, 2024 06:50
|
|