<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/102732>102732</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SPIR-V] Unexpected label emitted in SPIRVAsmPrinter when debug info is present
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
seven-mile
</td>
</tr>
</table>
<pre>
I used `-g` to emit debug info in Clang and get a LLVM IR module. When I tried to invoke `llc` and use SPIR-V backend to emit the final SPIR-V, an unexpected label is emitted after `OpFunctionEnd`:
```spirv
... omitted
OpBranchConditional %56 %61 %59
%59 = OpLabel
OpReturn
OpFunctionEnd
Lfunc_end0:
; -- End function
```
, which prevented the SPIR-V to be consumed by `spirv-as`. After disabling `-g`, the label is gone. I believe it's caused by these lines in the base class `AsmPrinter`:
https://github.com/llvm/llvm-project/blob/9a227ba3e129eaa89498b97421afefb1e9d681df/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp#L1945-L1949
We will need some overrides to disable this behaviour for SPIR-V.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVF1vqzgQ_TXmZRRkTIDwwEOb3qwiZdWrrrb3ceWPAbzXsZFt0u2_X5nQNLf7tAgZPB4fnzkzHh6CHixiR6pHUj1lfI6j813AC9rNWRvMhFPv3RHmgApITTcDqSlEB3jWERSKeQBtewfawt5wOwC3CgaMwOF0ev0dji9wdmo2mMOPES0cIXqNKkFoe3E_MaEaIxNs2joHhD--H182ryC4_IlW3U6LI0KvLTerA2F74BZmi_9MKCMqMFygAR0W_2TgfUSfTnieDrOVUTv7zSpSU1I-EPpE6MdY0-sbJu0vV1ue5-CuOFcDPE-Pnls57p1VOmFxA4RVVZ3Gulj-29V3fRYTkPIJnqdTYneDesE4e_ur968sl6VTP1v5F1r1SRlI-QibDXyzCvrV_0sY65Tt4W3UcoTJp4wmRZKIq77RgUCQzob5jArEO3wIsOGB1DSHh0U-pQMXRtvhVgAJOAHd9B6cxRyOINBovCDoSFgTQPKlbsR78g4IRlsMqVTSZsEDgjQ8hIT7EM7fvbYR_X-zM8Y4hWRjB8IOg47jLHLpzoQdjLl8fDaTd3-jjIQdhHGCsEPLGWsEL7FgLXK-a7ftTrTNlhW8x14U2Kp6V6j-DkenfXun8De0hB3uWN1PcjlNhJWnot1WmzS293R_ILxpY8AiKgjujOAu6L1WGJLmVzkR4qgDCBz5RbvZQ-_8mpj8CpOprlRt2fIMu6JhJWsaSuts7HZKVJXom0ZyWfa7WshWqpIXu4YrpBXNdMco29JdQemOlqzOJRV1WTWIxZaysu_JluKZa5OnsHPnh0yHMGNXUNaULFvSGpaewJjFN1hWCWOpRfhuEVvMQyBbanSI4RMm6miWZrLe0OoJ_vx6PT_uprZLvK-fssJb6hD3TSWkyg1oYzZ70_3vOlh4B8IOa2CXjv0bAAD__1N2ivM">