[LLVMbugs] [Bug 12667] New: LLVM reorders math function and the use of errno with -O2 on ARM

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 25 18:14:15 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12667

             Bug #: 12667
           Summary: LLVM reorders math function and the use of errno with
                    -O2 on ARM
           Product: new-bugs
           Version: trunk
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: weimingz at codeaurora.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8458
  --> http://llvm.org/bugs/attachment.cgi?id=8458
test case

#include <math.h>
#include <errno.h>
#include <stdio.h>

double foo() {
  double dummy;
  dummy = pow(-4.3, 1.1);
  printf("Errno=%d\n", errno);
  return dummy;
}

int main(int argc, char** argv) {
  double v = foo();
  printf("v=%f\n",v);
}


with -O0, the code will print Errno=33, which is expected.
However, with -O2, the code prints Errno=0

The asm code shows that, with -O2, the calls to pow and the printf are
reordered:

foo:
  push  {r11, lr}
  mov r11, sp
  bl  __errno_location
  ldr r1, [r0]
  ldr r0, .LCPI0_0
  bl  printf
  vldr  d16, .LCPI0_1
  vldr  d17, .LCPI0_2
  vmov  r0, r1, d16
  vmov  r2, r3, d17
  bl  pow
  pop {r11, lr}
  bx  lr
  .align  3

clang version 3.1 (branches/release_31 154941)
Target: arm-none-linux-gnueabi

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list