I'm at my wit's end. I've got a number of inlined functions that I absolutely need to inline because they're in a critical section of code, and I want to maintain the source-code conceptual modularity for having these as separate functions in the source code.
Code is structured vaguely like this (names changed for confidentiality; in reality Bar has 5 members and the total # of bottom-level int members is 14)
// bar.h
class Bar
{
class Baz
{
int x, y;
public:
inline Baz& copyFrom(const volatile Quux& other) { x = other.x; y = other.y; return *this;}
inline bool any() const volatile { return x != 0 || y != 0; }
};
class Quux
{
int z;
public:
inline Quux& copyFrom(const volatile Quux& other) { z = other.z; return *this;}
inline bool any() const volatile { return z != 0; }
};
Baz baz;
Quux quux;
public:
inline Bar& copyFrom(const volatile Bar& other) { baz.copyFrom(other.baz); quux.copyFrom(other.quux); return *this; }
inline bool any() const volatile { return baz.any() || quux.any(); }
};
// foo.h
class Foo
{
Bar bar;
volatile Bar vbar;
inline bool update() {
bar.copyFrom(vbar);
return bar.any();
}
void step();
}
// foo.cpp
void Foo::step()
{
if (update())
{
// do some other stuff
}
}
My problem is that the compiler doesn't inline Bar::copyFrom() or Bar::any(), instead generating separate functions with mangled names that start with ___CPR80__copyFrom__Q2_, which I assume is the compiler's way of telling me it tried really hard to inline the function but it failed.
These functions get called only once, and the function call overhead is really hurting me.
Is there a way to cajole the compiler into doing what I want? I've tried raising --auto_inline to a large value (8192) but it doesn't make a difference and from the docs, I assume --auto_inline allows me to limit inlining more than normal, but not encourage it.
Help!