[LLVMbugs] [Bug 17612] New: missed optimization for static constexpr field without definition

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Oct 18 03:29:23 PDT 2013


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

            Bug ID: 17612
           Summary: missed optimization for static constexpr field without
                    definition
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bruno-llvm at defraine.net
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11388
  --> http://llvm.org/bugs/attachment.cgi?id=11388&action=edit
test case

Consider the code in attachment. clang only properly optimizes the function
`f()' when it has a definition for the constexpr field `foo' in the same
compilation unit.

Note that I'm not complaining that I have to provide a definition for field
`foo'. But my choice for the compilation unit for this definition should not
affect performance?

$ clang++ -std=c++11 -O2 -Wall -c report.cpp && objdump -d report.o

report.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <_Z1fv>:
   0:    b8 01 00 00 00           mov    $0x1,%eax
   5:    83 3d 00 00 00 00 01     cmpl   $0x1,0x0(%rip)        # c <_Z1fv+0xc>
   c:    74 05                    je     13 <_Z1fv+0x13>
   e:    b8 02 00 00 00           mov    $0x2,%eax
  13:    c3                       retq   


$ clang++ -DDEF -std=c++11 -O2 -Wall -c report.cpp && objdump -d report.o

report.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <_Z1fv>:
   0:    b8 01 00 00 00           mov    $0x1,%eax
   5:    c3                       retq

-- 
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/20131018/7800e3e1/attachment.html>


More information about the llvm-bugs mailing list