[llvm] [SPIRV] Add support for SPV_KHR_abort extension (PR #193037)

Dmitry Sidorov via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 05:36:39 PDT 2026


================
@@ -595,6 +598,62 @@ SPIRVPrepareFunctions::removeAggregateTypesFromSignature(Function *F) {
   return NewF;
 }
 
+// Replace OpenCL/SPIR-V style calls to `__spirv_AbortKHR(message)` with calls
+// to the `llvm.spv.abort` target intrinsic, so that they go through the same
+// instruction-selection path as the intrinsic and get lowered to OpAbortKHR.
+bool SPIRVPrepareFunctions::substituteAbortKHRCalls(Function *F) {
+  if (F->isDeclaration())
+    return false;
+
+  SmallVector<CallInst *> Calls;
+  for (Instruction &I : instructions(F)) {
----------------
MrSidims wrote:

+1 to this. We can leave it as todo for now, but ultimately we should be lowering llvm.trap to spirv.abort. The Q would be: "what kind of message we should pass in this case?", may be something like: "abort is caused by llvm.trap with no debug string" is good enough.

https://github.com/llvm/llvm-project/pull/193037


More information about the llvm-commits mailing list