[clang] [CIR] Upstream support for function/call calling conventions (PR #181170)

Sirui Mu via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 08:42:35 PST 2026


================
@@ -176,6 +176,28 @@ mlir::LLVM::Linkage convertLinkage(cir::GlobalLinkageKind linkage) {
   llvm_unreachable("Unknown CIR linkage type");
 }
 
+static std::optional<mlir::LLVM::CConv>
+convertCallingConv(cir::CallingConv callingConv) {
+  using CIR = cir::CallingConv;
+  using LLVM = mlir::LLVM::CConv;
+
+  switch (callingConv) {
+  case CIR::C:
+    return LLVM::C;
+  case CIR::SpirKernel:
+    return LLVM::SPIR_KERNEL;
+  case CIR::SpirFunction:
+    return LLVM::SPIR_FUNC;
+  case CIR::OpenCLKernel:
+    llvm_unreachable("NYI");
----------------
Lancern wrote:

Add a missing feature assert here and return an empty `std::optional` value:

```suggestion
    assert(!cir::MissingFeatures::callConvOpenCLKernel());
    return std::nullopt;
```

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


More information about the cfe-commits mailing list