llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clangir @llvm/pr-subscribers-clang Author: Balaji V. Iyer. (bviyer) <details> <summary>Changes</summary> Set a `cir.sycl_device` module attribute in CIRGenModule when `LangOpts.SYCLIsDevice` and lower it to an LLVM `sycl-device` module flag. This lets consumer of hte emitted IR distinguish SYCL device modules from host modules. --- Full diff: https://github.com/llvm/llvm-project/pull/238117.diff 2 Files Affected: - (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+3) - (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp (+8) ``````````diff diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index 11904c58f82350..3a3a80935f0404 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -164,6 +164,9 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &mlirContext, spirMajor > 1 ? 0 : 2)); } } + if (langOpts.SYCLIsDevice) + getModule()->setAttr("cir.sycl_device", builder.getI32IntegerAttr(1)); + getModule()->setAttr(cir::CIRDialect::getTripleAttrName(), builder.getStringAttr(getTriple().str())); getModule()->setAttr(cir::CIRDialect::getTargetABIAttrName(), diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp index 2b80606fea6138..78e1fc86d9079b 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp @@ -219,6 +219,14 @@ class CIRDialectLLVMIRTranslationInterface } } + if (attribute.getName() == "cir.sycl_device") { + if (auto intAttr = + mlir::dyn_cast<mlir::IntegerAttr>(attribute.getValue())) { + llvmModule->addModuleFlag(llvm::Module::Error, "sycl-device", + static_cast<uint32_t>(intAttr.getInt())); + } + } + return mlir::success(); } }; `````````` </details> https://github.com/llvm/llvm-project/pull/238117 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
