[LLVMbugs] [Bug 23581] New: clang's -O implies -O2 whereas gcc's -O implies -O1

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 19 12:47:43 PDT 2015


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

            Bug ID: 23581
           Summary: clang's -O implies -O2 whereas gcc's -O implies -O1
           Product: clang
           Version: 3.6
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yanegomi at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I've been tracking down issues with debuggability on FreeBSD. It turns out that
the -O with clang means -O2, not -O1 like it does with gcc. From man gcc for
4.8.3:

       -O
       -O1 Optimize.  Optimizing compilation takes somewhat more time, and a
           lot more memory for a large function.

           With -O, the compiler tries to reduce code size and execution time,
           without performing any optimizations that take a great deal of
           compilation time.

           -O turns on the following optimization flags:

           -fauto-inc-dec -fcompare-elim -fcprop-registers -fdce -fdefer-pop
           -fdelayed-branch -fdse -fguess-branch-probability -fif-conversion2
           -fif-conversion -fipa-pure-const -fipa-profile -fipa-reference
           -fmerge-constants -fsplit-wide-types -ftree-bit-ccp
           -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copyrename
           -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop
           -ftree-fre -ftree-phiprop -ftree-slsr -ftree-sra -ftree-pta
           -ftree-ter -funit-at-a-time

           -O also turns on -fomit-frame-pointer on machines where doing so
           does not interfere with debugging.

>From man clang for 3.6.0:

             -O      Equivalent to -O2.

     -g      Generate debug information.  Note that Clang debug information
             works best at -O0.

It seems counterintuitive for projects that have used gcc for over a decade to
change behavior in this way. Why was this done/shouldn't clang pattern itself
after gcc to some degree?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150519/d7299b1f/attachment.html>


More information about the llvm-bugs mailing list