03-03-2011 01:30 AM
HP-UX v2 and v3
aCC: HP C/aC++ B3910B A.06.25.01 [May 16 2010]
For instance, we need to create two libraries: liba.so and libb.so
Library liba.so is built on basis of files a1.cpp, a2.cpp, ..., a1.h, a2.h, ...
Library libb.so is built on basis of files b1.cpp, b2.cpp, ..., b1.h, b2.h, ...
Files b1.h, b2.h, ... include some of files a1.h, a2.h, ...
Is it correct to compile liba.so with optimize mode O1, but libb.so with optimize mode O2?
Can that cause undefined behaviour (incuding crashing program that uses liba.so and libb.so)?
Solved! Go to Solution.
03-03-2011 04:56 AM
The "Level 1 optimzation" is the default, so it seems unlikely that O2 or any other opt level would have any potential to create undefined behavior when used with O1 libs, and if it did it would probably be considered a compiler bug. So my advice would be not to fret about it.
Level 1 Optimization
Level 1 optimization includes branch optimization, dead code elimination, faster register allocation, instruction scheduling, and peephole (statement-by-statement) optimization. Use +O1 to get level 1 optimization. Level 1 is the default.
Level 1 optimization produces faster programs than without optimization and compiles faster than level 2 optimization. Programs compiled at level 1 can be used with the HP Distributed Debugging Environment (DDE) debugger. Use the debugger option -g0 or -g1.
Level 2 Optimization
Level 2 optimization includes level 1 optimizations, plus optimizations performed over entire functions in a single file. Level 2 optimizes loops in order to reduce pipeline stalls and analyzes data-flow, memory usage, loops, and expressions. Use -O or +O2 to get level 2 optimization.
Specifically, level 2 provides:
* Coloring register allocation.
* Induction variable elimination and strength reduction.
* Local and global common subexpression elimination.
* Advanced constant folding and propagation. (Simple constant folding is done by default.)
* Loop invariant code motion.
* Store/copy optimization.
* Unused definition elimination.
* Software pipelining.
* Register reassociation.
Level 2 can produce faster run-time code than level 1 if programs use loops extensively. Loop-oriented floating-point intensive applications may see run times reduced by 50%. Operating system and interactive applications that use the already optimized system libraries can achieve 30% to 50% additional improvement. Level 2 optimization produces faster programs than level 1 and compiles faster than level 3 optimization.
03-05-2011 08:57 PM
> Yes, you can mix and match opt levels.
> Do you have any problems or just asking?
We have crashing some program. While investigating we check any thing that can cause the problem.
03-08-2011 06:09 AM
> You seem to be dying while creating a map<:rostringref> in MT_NBIRefMapping.cpp:50.
The developers try to investigate, localize and reproduce the situation.
When the situation reproduces, the relevent stuff will be send to the forum.
P.S The program is not mine. I was asked to ask of that in HP-forum.