[clang] [CIR] Initial implementation of CIR-to-LLVM IR lowering pass (PR #125260)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 3 10:51:01 PST 2025
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 2f6e3df08a8b7cd29273980e47310cf09c6fdbd8 4ec3c6d7d6b67fce27a50fea38f19d3d1bc42b1e --extensions h,cpp,c -- clang/include/clang/CIR/MissingFeatures.h clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h clang/test/CIR/Lowering/global-var-simple.cpp clang/include/clang/CIR/LowerToLLVM.h clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp clang/test/CIR/Lowering/hello.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 633a1f6910..af8ca7d0b8 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -88,7 +88,8 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite(
// Initializer is a constant floating-point number: convert to MLIR
// builtin constant.
init = rewriter.getFloatAttr(llvmType, fltAttr.getValue());
- } else if (const auto intAttr = mlir::dyn_cast<cir::IntAttr>(init.value())) {
+ } else if (const auto intAttr =
+ mlir::dyn_cast<cir::IntAttr>(init.value())) {
// Initializer is a constant array: convert it to a compatible llvm init.
init = rewriter.getIntegerAttr(llvmType, intAttr.getValue());
} else {
@@ -101,7 +102,7 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite(
rewriter.replaceOpWithNewOp<mlir::LLVM::GlobalOp>(
op, llvmType, isConst, linkage, symbol, init.value_or(mlir::Attribute()),
alignment, addrSpace, isDsoLocal, isThreadLocal,
- /*comdat=*/ mlir::SymbolRefAttr(), attributes);
+ /*comdat=*/mlir::SymbolRefAttr(), attributes);
return mlir::success();
}
@@ -186,8 +187,8 @@ lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp mlirModule, LLVMContext &llvmCtx) {
llvm::TimeTraceScope translateScope("translateModuleToLLVMIR");
StringRef moduleName = mlirModule.getName().value_or("CIRToLLVMModule");
- std::unique_ptr<llvm::Module> llvmModule = mlir::translateModuleToLLVMIR(
- mlirModule, llvmCtx, moduleName);
+ std::unique_ptr<llvm::Module> llvmModule =
+ mlir::translateModuleToLLVMIR(mlirModule, llvmCtx, moduleName);
if (!llvmModule) {
// FIXME: Handle any errors where they occurs and return a nullptr here.
``````````
</details>
https://github.com/llvm/llvm-project/pull/125260
More information about the cfe-commits
mailing list