[llvm-bugs] [Bug 34857] New: 8 bytes trivially copy constructible and destructible structure passed par memory instead of register
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Oct 5 23:20:20 PDT 2017
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: unassignedclangbugs at nondot.org
Reporter: abdoulk.keita at gmail.com
CC: dgregor at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171006/ee955a58/attachment.html>
More information about the llvm-bugs
mailing list