[clang] [CIR] Fix cir.call_llvm_intrinsic lowering for 0-result ops (PR #199516)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 1 00:42:33 PDT 2026
================
@@ -0,0 +1,27 @@
+// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s
+
+// Contract test for CIRToLLVMLLVMIntrinsicCallOpLowering: the op def
+// declares Optional<CIR_AnyType>:$result, so the lowering must accept
+// 0-result (void) calls in addition to the single-result case.
+
+!s32i = !cir.int<s, 32>
+
+module {
+ // 0-result, 0-operand.
+ // CHECK-LABEL: llvm.func @void_no_operands
+ // CHECK: llvm.call_intrinsic "llvm.donothing"() : () -> ()
+ // CHECK: llvm.return
+ cir.func @void_no_operands() {
+ cir.call_llvm_intrinsic "donothing" : () -> ()
----------------
skc7 wrote:
Hi @andykaylor
Agreed, ClangIR CIRGen never hits this path. But zero-result ops are valid IR per the op definition (Optional<CIR_AnyType>:$result), and out-of-tree MLIR producers lowering into `cir.call_llvm_intrinsic` can produce them and hit the OOB. This patch fixes that scenario.
https://github.com/llvm/llvm-project/pull/199516
More information about the cfe-commits
mailing list