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

            Bug ID: 17151
           Summary: missed optimization: unused std::string
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

>cat test.cpp
#include <string>

void foo() {
  std::string a = "abc";
}

void boo() {
}

Expected, that both 'foo' and 'boo' produce same asm, but it's not:

>clang++ -O3 -stdlib=libc++ -save-temps -O3 -c -fomit-frame-pointer test.cpp
>cat test.s
__Z3foov:                               ## @_Z3foov
    pushq    %rbx
    subq    $32, %rsp
    leaq    8(%rsp), %rbx
    leaq    L_.str(%rip), %rsi
    movq    %rbx, %rdi
    movl    $3, %edx
    callq   
__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm
    movq    %rbx, %rdi
    callq   
__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev
    addq    $32, %rsp
    popq    %rbx
    ret

__Z3boov:                               ## @_Z3boov
    ret

-- 
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