[llvm-branch-commits] [clang] [CIR] Add calling_conv attribute to FuncOp with lowering support (PR #189345)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Mar 30 02:41:30 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- clang/include/clang/CIR/MissingFeatures.h clang/lib/CIR/CodeGen/CIRGenCall.cpp clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp clang/lib/CIR/CodeGen/CIRGenModule.cpp clang/lib/CIR/Dialect/IR/CIRDialect.cpp clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenCall.cpp b/clang/lib/CIR/CodeGen/CIRGenCall.cpp
index dccb9fa09..ccb73a362 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCall.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCall.cpp
@@ -1295,7 +1295,7 @@ mlir::Value CIRGenFunction::emitRuntimeCall(mlir::Location loc,
                                             mlir::NamedAttrList attrs) {
 
   // TODO(cir): set the calling convention of the runtime function.
-                                              
+
   cir::CallOp call = builder.createCallOp(loc, callee, args);
   assert(call->getNumResults() <= 1 &&
          "runtime functions have at most 1 result");
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index a8ce4e9dd..2cd720b8f 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -2548,7 +2548,6 @@ void CIRGenModule::setCIRFunctionAttributes(GlobalDecl globalDecl,
   // TODO(cir): Apply the calling convention computed by constructAttributeList
   // to the function. Requires CodeGen target wiring (e.g., AMDGPU sets
   // AMDGPUKernel). See CIRGenModule::setCIRFunctionAttributes in OG.
-
 }
 
 void CIRGenModule::setFunctionAttributes(GlobalDecl globalDecl,
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index 736fe42cd..3c2d19b9d 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -2046,8 +2046,7 @@ static llvm::StringRef getLinkageAttrNameString() { return "linkage"; }
 
 void cir::FuncOp::build(OpBuilder &builder, OperationState &result,
                         StringRef name, FuncType type,
-                        GlobalLinkageKind linkage,
-                        CallingConv callingConv) {
+                        GlobalLinkageKind linkage, CallingConv callingConv) {
   result.addRegion();
   result.addAttribute(SymbolTable::getSymbolAttrName(),
                       builder.getStringAttr(name));
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 6f2ef7a42..367adac0e 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -187,18 +187,18 @@ static mlir::LLVM::CConv convertCallingConv(cir::CallingConv 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");
-    case CIR::PTXKernel:
-      return LLVM::PTX_Kernel;
-    case CIR::AMDGPUKernel:
-      return LLVM::AMDGPU_KERNEL;
+  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");
+  case CIR::PTXKernel:
+    return LLVM::PTX_Kernel;
+  case CIR::AMDGPUKernel:
+    return LLVM::AMDGPU_KERNEL;
   }
   llvm_unreachable("Unknown calling convention");
 }

``````````

</details>


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


More information about the llvm-branch-commits mailing list