<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/132464>132464</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MC] Regression regarding .safeseh in inline assembly
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mstorsjo
</td>
</tr>
</table>
<pre>
CC @MaskRay @lhmouse
There are two closely related regressions in the MC layer, since LLVM 19, regaring using `.safeseh` in inline assembly.
With the following reduced testcase as input:
```c
int foo(void) {
__asm__(".safeseh my_handler");
return 0;
}
```
Compiled like this:
```
$ clang -target i686-windows-msvc test.c -g
```
Before e48c4011ca80385573f1b92793c75dc98abb228f ([MC] Cache current fragment in MCStreamer), this runs succesfully. After that commit, it fails, triggering a failed assert:
```
clang: llvm/lib/MC/MCObjectStreamer.cpp:146: MCFragment *llvm::MCObjectStreamer::getCurrentFragment() const: Assertion `CurFrag->getParent() == getCurrentSection().first' failed.
```
If building with asserts disabled, it still succeeds, but closely thereafter, after 626eef5ecf92e98cbfccfa6134e0a760e7592813 ([MC] Optimize getCurrentSectionOnly using CurFrag and make it non-nullable), it also fails in a no-assert build, with the following error:
```
error: all .cv_loc directives for a function must be in the same section
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsVE2v4yYU_TVkcxXLxt8LL_ycRqo00VQzVbuMML62mYchApwo_fUVOHlvpqkUWQTugXM_zmHWikkhNiR_I_lhx1Y3a9Ms1mljf-hdr4d703VAsvjE7Ps3dvdLOS96tQgkbknc_jmjQWAGwd00cKktyjsYlMzhAAYng9YKrSwIBW5GOHUg2R0NoR1YoTjCly9_nSCp_YbBiRmhJlit_5Iijiwb0eJMitjfIJQUCoFZi0sv79FG4m_h5nD5qKXUNw81OKwcB3BoHWfWQ0Coy-pI2m4gUsTbj5O4FcrBqDWh1VWLgdAaSPlG4hbgfGZ2OZ8Jr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