Hi,
HP-UX B.11.23 U ia64
aCC: HP C/aC++ B3910B A.06.15 [May 16 2007]
I would like to get info of optimization level within compiled C/C++
program.
Something like (using preprocessing directives)
int foo()
{
#ifdef <something-0>
return 0; // optimization level == 0
#endif
#ifdef <something-1>
return 1; // optimization level == 1
#endif
...
}
Here are results of simple experiment.
--- empty.cpp ---
int main()
{
return 0;
}
-----------------
$ aCC -E -dM empty.cpp > ! pdm0
$ aCC -E -dM +O1 empty.cpp > ! pdm1
$ aCC -E -dM +O2 empty.cpp > ! pdm2
$ aCC -E -dM +O3 empty.cpp > ! pdm3
$ aCC -E -dM +O4 empty.cpp > ! pdm4
$ diff pdm0 pdm1
$ diff pdm0 pdm2
25a26
> #define __BUILTIN_MILLI 1
$ diff pdm0 pdm3
25a26
> #define __BUILTIN_MILLI 1
$ diff pdm0 pdm4
25a26
> #define __BUILTIN_MILLI 1
So, it seems that the only macros we can use is __BUILTIN_MILLI.
However, can __BUILTIN_MILLI be defined while optimization level < 2?
If it is true, it means that we can't use __BUILTIN_MILLI to detect
optimization level.
Is there other way to get info of optimization level within compiled C/
C++ program?
Thanks.
Alex Vinokur
|
|
0
|
|
|
|
Reply
|
Alex
|
5/5/2009 11:41:38 AM |
|
Alex Vinokur wrote:
> I would like to get info of optimization level within compiled C/C++
> program.
There aren't any defines. You could pass in an extra one when you add +O2.
> it seems that the only macros we can use is __BUILTIN_MILLI.
You aren't allowed to look at the define. In fact it is useless and may
be removed.
> Is there other way to get info of optimization level within compiled C/
> C++ program?
No, other than pass some define you invent.
|
|
0
|
|
|
|
Reply
|
Dennis
|
5/5/2009 11:36:42 PM
|
|