MD_FALLBACK_FRAME_STATE_FOR and floating point...

Andrew Haley aph@redhat.com
Tue Oct 21 20:15:00 GMT 2003


To put your mind at rest, try this example:

double barf (int n, double k)
{
  double m = (double)n*k;
  try
    {
      double b = (double)(n/n);
      if (b !=0)
	return 1;
    }
  catch (...)
    {
    }
  return m;
}

This is the code at -O2, the code on the right is the one with
-fnon-call-exceptions.  Note how in the latter case gcc stashes the
value for m on the stack.

Andrew.


.globl barf(int, double)                                        .globl barf(int, double)
        .type   barf(int, double), @function                            .type   barf(int, double), @function
barf(int, double):                                              barf(int, double):
.LFB2:                                                          .LFB2:
        pushl   %ebp    #                                               pushl   %ebp    #
.LCFI0:                                                         .LCFI0:
        movl    %esp, %ebp      #,                                      movl    %esp, %ebp      #,
.LCFI1:                                                         .LCFI1:
                                                              > .LEHB0:
                                                              >         subl    $24, %esp       #,
                                                              > .LCFI2:
        movl    8(%ebp), %eax   # n, n                                  movl    8(%ebp), %eax   # n, n
        pushl   %eax    # n                                   <
        cltd                                                            cltd
        idivl   %eax    # n                                   |         pushl   %eax    # n
        fildl   (%esp)  #                                               fildl   (%esp)  #
                                                              >         addl    $4, %esp        #,
        fmull   12(%ebp)        # k                                     fmull   12(%ebp)        # k
        movl    %eax, (%esp)    # tmp65,                      | .LEHE0:
                                                              >         fstpl   -8(%ebp)        # m
                                                              > .LEHB1:
                                                              >         idivl   %eax    # n
                                                              >         pushl   %eax    # tmp65
        fildl   (%esp)  #                                               fildl   (%esp)  #
        addl    $4, %esp        #,                            | .LEHE1:
        fldz                                                            fldz
        fxch    %st(1)  #                                               fxch    %st(1)  #
                                                              >         addl    $4, %esp        #,
                                                              > .LEHB2:
        fucompp                                                         fucompp
        fnstsw  %ax     #                                               fnstsw  %ax     #
        sahf                                                            sahf
        jp      .L12    #,                                    |         jp      .L13    #,
        jne     .L12    #,                                    |         jne     .L13    #,
                                                              >         fldl    -8(%ebp)        # m
                                                              >         leave
                                                              >         .p2align 4,,15
                                                              > .L16:
                                                              >         ret
                                                              >         .p2align 4,,7
                                                              > .L11:
.L5:                                                            .L5:
.L6:                                                            .L6:
        popl    %ebp    #                                     | .L8:
        ret                                                   |         movl    %eax, (%esp)    # tmp69,
.L12:                                                         |         call    __cxa_begin_catch       #
        fstp    %st(0)  #                                     |         call    __cxa_end_catch #
        popl    %ebp    #                                     |         fldl    -8(%ebp)        # m
                                                              >         leave
                                                              >         jmp     .L16    #
                                                              > .L13:
                                                              >         leave
                                                              > .LEHE2:
        fld1                                                            fld1
        ret                                                             ret
.LFE2:                                                          .LFE2:



More information about the Gcc mailing list