-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[MLIR][NFC] Fix build on recent GCC with C++20 enabled #73308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MLIR][NFC] Fix build on recent GCC with C++20 enabled #73308
Conversation
The following pattern fails on recent GCC versions with -std=c++20 flag passed and succeeds with -std=c++17. Such behavior is not observed on Clang 16.0. ``` template <typename T> struct Foo { Foo<T>(int a) {} }; ``` This patch removes template parameter from constructor in two occurences to make the following command complete successfully: bazel build -c fastbuild --cxxopt=-std=c++20 --host_cxxopt=-std=c++20 @llvm-project//mlir/... This patch is similar to https://reviews.llvm.org/D154782
@llvm/pr-subscribers-mlir-spirv @llvm/pr-subscribers-mlir Author: Alexander Batashev (alexbatashev) ChangesThe following pattern fails on recent GCC versions with -std=c++20 flag passed and succeeds with -std=c++17. Such behavior is not observed on Clang 16.0.
This patch removes template parameter from constructor in two occurences to make the following command complete successfully: This patch is similar to https://reviews.llvm.org/D154782 Full diff: https://github.com/llvm/llvm-project/pull/73308.diff 4 Files Affected:
diff --git a/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp b/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp
index 3b8338673a5e32e..b3762f0293492ca 100644
--- a/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp
+++ b/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp
@@ -55,10 +55,8 @@ template <typename Op, typename TypeResolver = ComplexTypeResolver>
struct ScalarOpToLibmCall : public OpRewritePattern<Op> {
public:
using OpRewritePattern<Op>::OpRewritePattern;
- ScalarOpToLibmCall<Op, TypeResolver>(MLIRContext *context,
- StringRef floatFunc,
- StringRef doubleFunc,
- PatternBenefit benefit)
+ ScalarOpToLibmCall(MLIRContext *context, StringRef floatFunc,
+ StringRef doubleFunc, PatternBenefit benefit)
: OpRewritePattern<Op>(context, benefit), floatFunc(floatFunc),
doubleFunc(doubleFunc){};
diff --git a/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp b/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp
index 7fd94116ef7a6eb..103c1fb8c3822ec 100644
--- a/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp
+++ b/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp
@@ -50,8 +50,8 @@ template <typename Op>
struct ScalarOpToLibmCall : public OpRewritePattern<Op> {
public:
using OpRewritePattern<Op>::OpRewritePattern;
- ScalarOpToLibmCall<Op>(MLIRContext *context, StringRef floatFunc,
- StringRef doubleFunc)
+ ScalarOpToLibmCall(MLIRContext *context, StringRef floatFunc,
+ StringRef doubleFunc)
: OpRewritePattern<Op>(context), floatFunc(floatFunc),
doubleFunc(doubleFunc){};
diff --git a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
index e749f2bc101297d..febfe97f6c0a997 100644
--- a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
+++ b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
@@ -96,8 +96,8 @@ Region::iterator getBlockIt(Region ®ion, unsigned index) {
template <typename OpTy>
class SCFToSPIRVPattern : public OpConversionPattern<OpTy> {
public:
- SCFToSPIRVPattern<OpTy>(MLIRContext *context, SPIRVTypeConverter &converter,
- ScfToSPIRVContextImpl *scfToSPIRVContext)
+ SCFToSPIRVPattern(MLIRContext *context, SPIRVTypeConverter &converter,
+ ScfToSPIRVContextImpl *scfToSPIRVContext)
: OpConversionPattern<OpTy>::OpConversionPattern(converter, context),
scfToSPIRVContext(scfToSPIRVContext), typeConverter(converter) {}
diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp
index b0c314369190a40..35ac4b8fd280eab 100644
--- a/mlir/lib/Pass/PassRegistry.cpp
+++ b/mlir/lib/Pass/PassRegistry.cpp
@@ -373,7 +373,7 @@ llvm::cl::OptionValue<OpPassManager>::operator=(
return *this;
}
-llvm::cl::OptionValue<OpPassManager>::~OptionValue<OpPassManager>() = default;
+llvm::cl::OptionValue<OpPassManager>::~OptionValue() = default;
void llvm::cl::OptionValue<OpPassManager>::setValue(
const OpPassManager &newValue) {
|
@llvm/pr-subscribers-mlir-core Author: Alexander Batashev (alexbatashev) ChangesThe following pattern fails on recent GCC versions with -std=c++20 flag passed and succeeds with -std=c++17. Such behavior is not observed on Clang 16.0.
This patch removes template parameter from constructor in two occurences to make the following command complete successfully: This patch is similar to https://reviews.llvm.org/D154782 Full diff: https://github.com/llvm/llvm-project/pull/73308.diff 4 Files Affected:
diff --git a/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp b/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp
index 3b8338673a5e32e..b3762f0293492ca 100644
--- a/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp
+++ b/mlir/lib/Conversion/ComplexToLibm/ComplexToLibm.cpp
@@ -55,10 +55,8 @@ template <typename Op, typename TypeResolver = ComplexTypeResolver>
struct ScalarOpToLibmCall : public OpRewritePattern<Op> {
public:
using OpRewritePattern<Op>::OpRewritePattern;
- ScalarOpToLibmCall<Op, TypeResolver>(MLIRContext *context,
- StringRef floatFunc,
- StringRef doubleFunc,
- PatternBenefit benefit)
+ ScalarOpToLibmCall(MLIRContext *context, StringRef floatFunc,
+ StringRef doubleFunc, PatternBenefit benefit)
: OpRewritePattern<Op>(context, benefit), floatFunc(floatFunc),
doubleFunc(doubleFunc){};
diff --git a/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp b/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp
index 7fd94116ef7a6eb..103c1fb8c3822ec 100644
--- a/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp
+++ b/mlir/lib/Conversion/MathToLibm/MathToLibm.cpp
@@ -50,8 +50,8 @@ template <typename Op>
struct ScalarOpToLibmCall : public OpRewritePattern<Op> {
public:
using OpRewritePattern<Op>::OpRewritePattern;
- ScalarOpToLibmCall<Op>(MLIRContext *context, StringRef floatFunc,
- StringRef doubleFunc)
+ ScalarOpToLibmCall(MLIRContext *context, StringRef floatFunc,
+ StringRef doubleFunc)
: OpRewritePattern<Op>(context), floatFunc(floatFunc),
doubleFunc(doubleFunc){};
diff --git a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
index e749f2bc101297d..febfe97f6c0a997 100644
--- a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
+++ b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
@@ -96,8 +96,8 @@ Region::iterator getBlockIt(Region ®ion, unsigned index) {
template <typename OpTy>
class SCFToSPIRVPattern : public OpConversionPattern<OpTy> {
public:
- SCFToSPIRVPattern<OpTy>(MLIRContext *context, SPIRVTypeConverter &converter,
- ScfToSPIRVContextImpl *scfToSPIRVContext)
+ SCFToSPIRVPattern(MLIRContext *context, SPIRVTypeConverter &converter,
+ ScfToSPIRVContextImpl *scfToSPIRVContext)
: OpConversionPattern<OpTy>::OpConversionPattern(converter, context),
scfToSPIRVContext(scfToSPIRVContext), typeConverter(converter) {}
diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp
index b0c314369190a40..35ac4b8fd280eab 100644
--- a/mlir/lib/Pass/PassRegistry.cpp
+++ b/mlir/lib/Pass/PassRegistry.cpp
@@ -373,7 +373,7 @@ llvm::cl::OptionValue<OpPassManager>::operator=(
return *this;
}
-llvm::cl::OptionValue<OpPassManager>::~OptionValue<OpPassManager>() = default;
+llvm::cl::OptionValue<OpPassManager>::~OptionValue() = default;
void llvm::cl::OptionValue<OpPassManager>::setValue(
const OpPassManager &newValue) {
|
The following pattern fails on recent GCC versions with -std=c++20 flag passed and succeeds with -std=c++17. Such behavior is not observed on Clang 16.0.
This patch removes template parameter from constructor in two occurences to make the following command complete successfully:
bazel build -c fastbuild --cxxopt=-std=c++20 --host_cxxopt=-std=c++20 @llvm-project//mlir/...
This patch is similar to https://reviews.llvm.org/D154782