<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59974>59974</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
__attribute__((cold)) causes unaligned functions with optimization
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:optimizations
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pogo59
</td>
</tr>
</table>
<pre>
The "cold" attribute suppresses function alignment if I compile with optimization.
```
$ cat t.cpp
#ifdef BAD
#define COLD __attribute__((cold))
#else
#define COLD
#endif
COLD int a() { return 1; }
$ clang -S t.cpp -o - -O1 | grep p2align
.p2align 4, 0x90
$ clang -S t.cpp -o - -O0 | grep p2align
.p2align 4, 0x90
$ clang -S t.cpp -o - -O1 -DBAD | grep p2align
$ clang -S t.cpp -o - -O0 -DBAD | grep p2align
.p2align 4, 0x90
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysk02PmzAQhn_NcBmBzGDCcuCQLIpUqdIe2ntk8Ji4cjDCpl-_vgpkP9Rt00stS8jDzKvH43lVCHYYmRsoD1C2iVri2c_N5Adf1knn9Y_m85kRiHrvNBChinG23RIZwzJNM4fAAc0y9tH6EZWzw3jhMaI1-AF7f5msY_xm4xn9FO3F_lTXxAxEC2IPO3Hb25Ek9ipizPppeg4V1mg2eNi3LxHNxo6Mj08fWzydXohOJ6AHoIcNtb7u5wp2gf9U_powamu20yprx4hqlasRqgPOHJd5xByKA0LVvuF1ahww_bRBY-oxxfQpR6gecZh5wonWpmwVeFvZLYoS6BHF91r8S1H8d8Uc0_awb_-ie4_kXt07ntv6Hev55RPdFLouapVwk--qoizpoZLJuRFdx1ILWZZGGrOjXpiORb2rNJldr1ViGxJUiDynvJZVKbNcFoYEsdF1VXW6Byn4oqzLnPt6yfw8JDaEhZuyriuZONWxC-vgE10zoNi_HdEARFdLzM31Z9otQwApnA0xvApGGx03d2cQe7VcPbKMaz9Yv7glvPdFssyuOcc4BSj2QEeg42Djeemy3l-Ajivn9kmn2X_hPgId12sFoON6s18BAAD__87pIX4">