Hello
I ran into a problem where the compiler emits very pessimistic code when I think it really shouldn't. I wonder who's wrong, though. Consider the following C++ code:
struct Test { #ifndef MAKEPOD Test(const Test& t) : x(t.x) {} #endif int x; }; void SomeOtherFunction(Test t); void DontCall(); void SomeFunction(Test t) { Test t2 = t; t.x = 0; SomeOtherFunction(t2); if(t.x) { DontCall(); } }
If I define MAKEPOD, the code is compiled to a single CALLRET instruction calling SomeOtherFunction. When I don't, the code saves a couple of registers and also includes a conditional call of DontCall(). That doesn't seem right to me. In my application, this would affect the use of a unique_ptr-like smart pointer, where deleter code is emitted all over the place, even if the (local) unique_ptr previously released its pointer (the situation is thus very similar to the above).
I am using CGT 7.4.7, the compiler flags were
-mv6400 --abi=eabi -O3 --rtti --cpp_default --gcc --display_error_number --interrupt_threshold=1024 --mem_model:const=far --mem_model:data=far --opt_for_speed=2 --gen_opt_info=2 --call_assumptions=0 --std_lib_func_not_defined -k --src_interlist
Am I missing something?
Kind regards
Markus