Skip to content

Commit 8fa431c

Browse files
gitolegsmeenai
authored andcommitted
[CIR][Bugfix] renames minor/major parameters of the OpenCLVersionAttr (llvm#845)
Looks like certain names should not be used - I even could not build CIR on the Ubuntu with a relatively old glibc version. In this case `minor` and `major` are macroses and can not be used in this context. You can take a look at the comments in the [mlir/test/lib/Dialect/Test/TestDialect.h](https://github.com/llvm/clangir/blob/main/mlir/test/lib/Dialect/Test/TestDialect.h#L70) reference as well
1 parent f3e5669 commit 8fa431c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def OpenCLKernelArgMetadataAttr
153153

154154
def OpenCLVersionAttr : CIR_Attr<"OpenCLVersion", "cl.version"> {
155155
let summary = "OpenCL version";
156-
let parameters = (ins "int32_t":$major, "int32_t":$minor);
156+
let parameters = (ins "int32_t":$major_version, "int32_t":$minor_version);
157157
let description = [{
158158
Represents the version of OpenCL.
159159

@@ -165,7 +165,7 @@ def OpenCLVersionAttr : CIR_Attr<"OpenCLVersion", "cl.version"> {
165165
module attributes {cir.cl.version = cir.cl.version<3, 0>} {}
166166
```
167167
}];
168-
let assemblyFormat = "`<` $major `,` $minor `>`";
168+
let assemblyFormat = "`<` $major_version `,` $minor_version `>`";
169169
}
170170

171171
#endif // MLIR_CIR_DIALECT_CIR_OPENCL_ATTRS

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ class CIRDialectLLVMIRTranslationInterface
7373
auto *int32Ty = llvm::IntegerType::get(llvmContext, 32);
7474
llvm::Metadata *oclVerElts[] = {
7575
llvm::ConstantAsMetadata::get(
76-
llvm::ConstantInt::get(int32Ty, openclVersionAttr.getMajor())),
76+
llvm::ConstantInt::get(int32Ty, openclVersionAttr.getMajorVersion())),
7777
llvm::ConstantAsMetadata::get(
78-
llvm::ConstantInt::get(int32Ty, openclVersionAttr.getMinor()))};
78+
llvm::ConstantInt::get(int32Ty, openclVersionAttr.getMinorVersion()))};
7979
llvm::NamedMDNode *oclVerMD =
8080
llvmModule->getOrInsertNamedMetadata("opencl.ocl.version");
8181
oclVerMD->addOperand(llvm::MDNode::get(llvmContext, oclVerElts));

0 commit comments

Comments
 (0)