<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121151>121151</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang: -finstrument-functions does not insert '__cyg_profile_func_exit' when using throw expression in c++
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ggstone0523
</td>
</tr>
</table>
<pre>
'-finstrument-functions' option does not insert '__cyg_profile_func_exit' to function that using throw expression.
code :
```c++
#include <stdexcept>
void A()
{
throw std::runtime_error("!");
};
int main()
{
try {
A();
} catch( ... ) {
}
return 0;
}
```
run
```
clang++ ./test.cpp -finstrument-functions
```
result of disassemble using objdump
```
...
00000000000011a0 <_Z1Av>:
11a0: 55 push %rbp
11a1: 48 89 e5 mov %rsp,%rbp
11a4: 48 83 ec 20 sub $0x20,%rsp
11a8: 48 8b 75 08 mov 0x8(%rbp),%rsi
11ac: 48 8d 3d ed ff ff ff lea -0x13(%rip),%rdi # 11a0 <_Z1Av>
11b3: e8 78 fe ff ff call 1030 <__cyg_profile_func_enter@plt>
11b8: bf 10 00 00 00 mov $0x10,%edi
11bd: e8 8e fe ff ff call 1050 <__cxa_allocate_exception@plt>
11c2: 48 89 c7 mov %rax,%rdi
11c5: 48 89 f8 mov %rdi,%rax
11c8: 48 89 45 e8 mov %rax,-0x18(%rbp)
11cc: 48 8d 35 31 0e 00 00 lea 0xe31(%rip),%rsi # 2004 <_IO_stdin_used+0x4>
11d3: e8 68 fe ff ff call 1040 <_ZNSt13runtime_errorC1EPKc@plt>
11d8: e9 00 00 00 00 jmp 11dd <_Z1Av+0x3d>
11dd: 48 8b 7d e8 mov -0x18(%rbp),%rdi
11e1: 48 8b 35 10 2e 00 00 mov 0x2e10(%rip),%rsi # 3ff8 <_ZTISt13runtime_error@GLIBCXX_3.4>
11e8: 48 8b 15 e9 2d 00 00 mov 0x2de9(%rip),%rdx # 3fd8 <_ZNSt13runtime_errorD1Ev@GLIBCXX_3.4>
11ef: e8 8c fe ff ff call 1080 <__cxa_throw@plt>
11f4: 48 8b 7d e8 mov -0x18(%rbp),%rdi
11f8: 48 89 c1 mov %rax,%rcx
11fb: 89 d0 mov %edx,%eax
11fd: 48 89 4d f8 mov %rcx,-0x8(%rbp)
1201: 89 45 f4 mov %eax,-0xc(%rbp)
1204: e8 57 fe ff ff call 1060 <__cxa_free_exception@plt>
1209: 48 8b 7d f8 mov -0x8(%rbp),%rdi
120d: e8 7e fe ff ff call 1090 <_Unwind_Resume@plt>
1212: 66 66 66 66 66 2e 0f data16 data16 data16 data16 cs nopw 0x0(%rax,%rax,1)
1219: 1f 84 00 00 00 00 00
...
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVl2PozYX_jXOzdFE_oAAF7nIzOy8Wr1VW_VDWvUGGfuQeEUAYZNh_31lICEEZtoiNCDi8_j4-fBYWmuOJeKehM8kfN3I1p2qZn88WleVSEMuNlmlf-wJj55yU1rXtGcs3VPelsqZqrSER1DV_hV0hRbKyoEpLTYOCI_SVP04pnVT5abA1Bel2Bnni1wFVxBwJ-mgtaY8gjs11TtgVzdoranKLaEHQg-q0ghE-Feyo8OtCH_2Nz0QLkypirYf82Kdxk5h7Yj4MlRfKqPhQHhMeOK_RL5onMo67XHFoWlLZ86YYtNUTT-WE876vwkR_TTR6_hCD6Z0cJamfAQdL9f8gPHLdV5x_zuJXkFJp06Ex7DdboHwBOYQfrZ-quuHBl3blECnZu7IINQv4OGLKmR5HFiCLeFvDq3bqrqGD7ScV3tItG3hoMpBGyutxXNW4KhUlX3X7bl-KNpuvWL07mJMUi9L-hc7XLwk4roo_wsR1_WFIdStPfmV87DJ6mkQmwYFMcQJYAgP17m69GW2JvzlsT6Y1wtABZzO6m2b9ZzzgHacjhi2x2BMxnOADKIQaLxoAABoF_dy9w3w5ApkpmbUHEuD0IAa8ny8AaBA6R9PtGNiRDN3aNrc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