Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
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 ...

Adbot
ADBOT LOVES YOU

  • Locked thread