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

            Bug ID: 34857
           Summary: 8 bytes trivially copy constructible and destructible
                    structure passed par memory instead of register
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangb...@nondot.org
          Reporter: abdoulk.ke...@gmail.com
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org

The structure X in the following code snippet is both trivially_destructible
and trivially_copyable, but is not pass by register as required but section
3.2.3 of the ABI document
https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-r252.pdf

#include <type_traits>

struct X {
    X&operator=(X&&) = delete;
    X&operator=(const X&) = default;
    long x;
};

bool foo() {
    return std::is_trivially_destructible<X>::value;
}

bool bar() {
    return std::is_trivially_copyable<X>::value;
}

int testingfunc(X x){
    return x.x;
}



With clang version >= 5.0 at -O3 -std=c++14 , Compiles to  : 
foo(): # @foo()
  mov al, 1
  ret
bar(): # @bar()
  mov al, 1
  ret

testingfunc(X): # @testingfunc(X)
  mov eax, dword ptr [rdi]
  ret

With clang version <= 4.0.0, and all gcc versions : 
foo(): # @foo()
  mov al, 1
  ret

bar(): # @bar()
  mov al, 1
  ret

testingfunc(X): # @testingfunc(X)
  mov eax, edi
  ret

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