<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Chandler,<br>
<br>
your recent changes for:<br>
[ADT] Add llvm::unique_function which is like std::function but
supporting move-only closures.<br>
(<a class="moz-txt-link-freetext" href="https://reviews.llvm.org/rL336156">https://reviews.llvm.org/rL336156</a>)<br>
<br>
lead to FunctionExtrasTest unit test failing with asserts about
function-pointer alignment<br>
when compiled with gcc4.9.2 on a variety of x86-Linuxes.<br>
<br>
It appears that gcc4.9.2 generates function pointers to lambdas
aligned by 2, not by 4.<br>
<br>
Simple checker testcase:<br>
<a class="moz-txt-link-freetext" href="https://godbolt.org/g/9sKLQx">https://godbolt.org/g/9sKLQx</a><br>
<br>
] gcc --version<br>
gcc (GCC) 4.9.2<br>
Copyright (C) 2014 Free Software Foundation, Inc.<br>
This is free software; see the source for copying conditions. There
is NO<br>
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.<br>
] gcc check_lambda_align.cc -std=c++11<br>
] ./a.out<br>
Alignment NOT satisfied for an actual function pointer to lambda!
0x400536<br>
Alignment OK for lambda pointer! 0x400580<br>
Alignment NOT satisfied for an actual function pointer to lambda!
0x4005ca<br>
Alignment OK for lambda pointer! 0x400614<br>
Alignment NOT satisfied for an actual function pointer to lambda!
0x40065e<br>
]<br>
<br>
<span style="color: #008080;">gcc5.4 appears to do the same.<br>
clang is fine (aligns by 8).<br>
<br>
</span>(you can check assembler generated by gcc at that godbolt.org
link above:<br>
<div style="color: #000000;background-color: #fffffe;font-family:
Consolas, ">
<div><span style="color: #000000;"> </span><span style="color:
#0000ff;">.align</span><span style="color: #000000;"> </span><span
style="color: #09885a;">2</span></div>
<div><span style="color: #000000;"> </span><span style="color:
#0000ff;">.type</span><span style="color: #000000;"> </span><span
style="color: #008080;">main</span><span style="color:
#000000;">::{</span><span style="color: #008080;">lambda</span><span
style="color: #000000;">(</span><span style="color: #008080;">int</span><span
style="color: #000000;">, </span><span style="color:
#008080;">int</span><span style="color: #000000;">)</span><span
style="color: #09885a;">#1</span><span style="color: #000000;">}::</span><span
style="color: #008080;">_FUN</span><span style="color:
#000000;">(</span><span style="color: #008080;">int</span><span
style="color: #000000;">, </span><span style="color:
#008080;">int</span><span style="color: #000000;">), </span><span
style="color: #008080;">@function</span></div>
<div><span style="color: #008080;">main::{lambda(int,
int)#1}::_FUN(int, int):</span></div>
<div><span style="color: #008080;">)<br>
<br>
Can we, please, do something about it? :)<br>
<br>
regards,<br>
Fedor.<br>
</span></div>
</div>
</body>
</html>