https://llvm.org/bugs/show_bug.cgi?id=27531

            Bug ID: 27531
           Summary: Shrink-wrapping clobbers live EFLAGS value
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedb...@nondot.org
          Reporter: h...@chromium.org
                CC: llvm-bugs@lists.llvm.org, qcolom...@apple.com
    Classification: Unclassified

a.cc:

  struct S {
    void foo();
    void bar(const int*, double*);
    int x_;
  };

  void S::foo() {
    int data[] = { x_ > 32 ? 42 : 128 };

    if (x_ <= 31)
      return;

    double d;
    bar(data, &d);
  }

Compiled like this:

$ bin/clang -target i686-pc-win32 -Os -S -o - /tmp/a.cc -march=i686

Yields the following output:

"?foo@S@@QAEXXZ":                       # @"\01?foo@S@@QAEXXZ"
# BB#0:                                 # %entry
        cmpl    $32, (%ecx)
        movl    $42, %eax
        jg      LBB0_2       <---- Sets EFLAGS
# BB#1:                                 # %entry
        movl    $128, %eax
LBB0_2:                                 # %entry
        pushl   %ebp
        movl    %esp, %ebp
        andl    $-8, %esp    <---- Clobbers EFLAGS
        leal    -16(%esp), %esp
        movl    %eax, 4(%esp)
        jl      LBB0_4       <---- Was depending on EFLAGS
# BB#3:                                 # %if.end
        leal    8(%esp), %eax
        leal    4(%esp), %edx
        pushl   %eax
        pushl   %edx
        calll   "?bar@S@@QAEXPBHPAN@Z"
LBB0_4:                                 # %cleanup
        movl    %ebp, %esp
        popl    %ebp
        retl

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to