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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to