<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/133143>133143</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang 19.1.7 crash during lambda compilation with naked attribute
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          alpluspluss
      </td>
    </tr>
</table>

<pre>
    Version: 19.1.7
Host OS: macOS Sonoma 14.4
Flags: -ffreestanding -mcmodel=kernel
Target: x86_64-none-elf

Code:
```cpp
/* syscall entry point */
static auto syscall_entry = []() __attribute__((naked))
{
    asm volatile(
        "swapgs\n"
        "movq %rsp, %gs:16\n"
 "movq %gs:8, %rsp\n"
        "ret"
    );
};
```

I happened to run into a crash when compiling kernel code using a lambda with `__attribute__((naked))`.
This code doesn't crash during compilation with `x86_64-elf-g++`. I may be able to contribute a fix for this issue if needed.

Link to the attached file as I am not able to attach it normally: https://pastebin.com/GzeB8ga7

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEU11vrDYQ_TXmZbTImOXrgQc2q20jVboPqfq6GmAAN8amtknu9tdXBm5uolYqMsLMHM_HOWN0To6aqGbZhWXXCFc_GVujWtTqwuui1vSP-g-yThrN0gaSKk7igvHmV-M8fHsJthm7by_wYrSZEZJzfGa8uSkcXXCehsESOY-6l3qE09zNpifF0usrWU2K8eZ3tCP5AP5e5vf8fNJG04nUwHjDePNkemJp2LGc76tblvArbkw04B6uQ6WAtLcPWIzUHpjYvLxxHr3sAFdvfgDvO5ClV9j7ZqJkooL7Hb23sl093e-brdT4Sj0TVVi8YcWF8QYAAN0Mb0ahl4oCcreGhwnh3nEZHcueNBPiq2s2b38BE5l1CxNPYbeRlOSf0J9gm7M8kOHMf8W05H_aQqHpZav1emx-cLaT-QwTLgtp6sEbsKsGqb0BhM6im-B9Ig2dmRepglq7RNCZnmB1wYKgcG57hHfpJ2A5_x_Wch4HhSfp9ii9IaeZKPyRsF9tCLunRC-N_oh8DAOp4TQycQkr5zE8w4wPaAmwVRSa6Iw-CgCEQX6HwVjwIaN0biWQA2iinvp4p-A3qV_DOT8RoPfYTdTDIBUBOngGnEEb_xF9R4D0oI2dUalHGNTJ-yWIs43gbUHnqZU67szMxO2Xv-lSjhhuSdTXaV-lFUZUJ8U55UlepFk01V1ZtG0h8hLPVIh2EL2ohrblGXW8yMs0krXgIuOpyJMqKbMs5mma5UOZJclQDbkgduY0o1SxUm9zbOwYbe3WSZom5zRS2JJy280WolOoxzAl2TWydThwatfRsTNX0nn3M4SXXlH9FODHVf-q0yH-v-TaJIePSYhWq-qvHI3ST2t7MBTyHZ_TYs2f1Hkmblv9jonb0cJbLf4JAAD___qwbJk">