Hi,
I'm coding in C++ and we defined several objects which inherit from the same interface. This interface is an abstract class which list several pure virtual functions that need to be defined by the derived clases.
The problem I'm facing is the following: the compiler doesn't compile efficiently my code when accessing one of those redefined virtual functions. In term of cycles, if I declare my function virtual in my interface I measure 44 cycles, if I remove the virtualization of my function (which means it is simple inheritance and the function to be call is know at compile time) it takes 4 cycles. It may not seems much like that but represent 40 cycles -> 0.41% CPU time (at 16.4kHz loop) and if I have 25 of those calls I'm loosing 10.25% of my whole CPU time!
The following scenario shows what I'm doing:
class Base {
public:
virtual void foo( ) = 0;
};
class Derived : public Base {
public:
void foo( ) { //Do something }
};
void CallFoo(
Base* p
) {
p->foo( ); // Calls the derived version
}
int main( ) {
Derived a;
CallFoo(&a)
}
Please let me know if it is a known issue (limitation). I'm using TMS570Ls2 with compiler 4.9.0.
Thank you.