Operating System - HP-UX
1748114 Members
3305 Online
108758 Solutions
New Discussion

Re: +O2 optimization question - core dump with BUS_ADRALN

 
rayvd
Advisor

+O2 optimization question - core dump with BUS_ADRALN

I have an application running perfectly fine on most other platforms (Linux, Solaris, AIX 32 and 64-bit) but crashes on HP-UX 11.23 IA when compiled with the +O2 optimization option in 64-bit mode. When I re-compile with optimization set to +O1 for a specific function it runs fine. The crash is happening as soon as the function(LinearRingArea) is being invoked.
Both the caller and callee functions are in the same object file. Here is the difference in the assembly code with +O1 and +O2:

O1:
;;; 4713 {
0x9fffffffec88c640:0 :
alloc r37=ar.pfs,0,7,1,0
0x9fffffffec88c640:1 : mov r38=b0
0x9fffffffec88c640:2 :
adds r12=-80,r12;;
0x9fffffffec88c650:0 :
adds r9=16,r12
0x9fffffffec88c650:1 :
adds r10=32,r12;;
0x9fffffffec88c650:2 : nop.i 0x0
0x9fffffffec88c660:0 :
stf.spill [r9]=f16,32
0x9fffffffec88c660:1 :
stf.spill [r10]=f17,32
0x9fffffffec88c660:2 : nop.i 0x0;;
0x9fffffffec88c670:0 :
stf.spill [r9]=f18,32
0x9fffffffec88c670:1 :
stf.spill [r10]=f19,32
0x9fffffffec88c670:2 : nop.i 0x0;;
0x9fffffffec88c680:0 :
stf.spill [r9]=f20,16
---Type to continue, or q to quit---
0x9fffffffec88c680:1 : mov r35=r33
0x9fffffffec88c680:2 :
mov r34=r32;;

O2:
;;; 4713 {
0x9fffffffec88e440:0 : adds r10=-1,r32
0x9fffffffec88e440:1 :
---Type to continue, or q to quit---
adds r15=8,r33
0x9fffffffec88e440:2 : mov r8=pr
0x9fffffffec88e450:0 :
adds r16=16,r33
0x9fffffffec88e450:1 :
adds r14=-3,r32
0x9fffffffec88e450:2 :
adds r11=32,r33;;
0x9fffffffec88e460:0 :
ldfd f10=[r15]
0x9fffffffec88e460:1 : ldfd f9=[r16]
0x9fffffffec88e460:2 : sxt4 r15=r10

LinearRingArea takes a 2 arguments:
1> A point to a structure containing 2 double variables
2> An int.
I need some insights to understand the root cause. Also, are there any compile time options to turn off specific level 2 optimizations? Are the floating point optimizations causing the crash?
1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: +O2 optimization question - core dump with BUS_ADRALN

>The crash is happening as soon as the function(LinearRingArea) is being invoked.

What aCC6 version are you using? The latest is A.06.23, PHSS_39823.

Which instruction? ldfd f10=[r15] ?

>Here is the difference in the assembly code with +O1 and +O2:

You don't have enough instructions for your +O1 code to compare.

>LinearRingArea takes a 2 arguments:

It appears you have reversed them in your description:
LinearRingArea(int x, struct foo *p)

>are there any compile time options to turn off specific level 2 optimizations?

What type? There doesn't seem to be any optimizations yet, other than loading the two double fields.

>Are the floating point optimizations causing the crash?

Not sure. What are the values of r33, r15 and r16? r33 must be 8 byte aligned.