Skip to content

Commit

Permalink
Integrate LLVM at llvm/llvm-project@a6d932b (#16944)
Browse files Browse the repository at this point in the history
IREE-side changes to adapt to MLIR changes:
1. `initializeOptions` changes to adapt to
llvm/llvm-project#87289
2. `enableFastMathMode` removal:
llvm/llvm-project#86578.
3. Bazel changes to adapt to
llvm/llvm-project#86819

IREE-side fixes for preexisting bugs revealed by a MLIR change:
1. `mlp_tosa` test fix: the shapes were inconsistent, used to
accidentally work, until MLIR started catching it since
llvm/llvm-project#85798. See diagnostic in
[87396](llvm/llvm-project#87396 (comment)).
FYI @MaheshRavishankar.

IREE-side fixes accidentally lumped into this:
1. The `iree_copts.cmake` change: It just happens that my bleeding-edge
Clang was updated and started diagnosing some code relying on C++20
semantics. Filed #16946 as TODO.

---------

Co-authored-by: Scott Todd <scott.todd0@gmail.com>
  • Loading branch information
bjacob and ScottTodd authored Apr 3, 2024
1 parent 2c88e49 commit 3fa9fbd
Show file tree
Hide file tree
Showing 127 changed files with 201 additions and 61 deletions.
4 changes: 3 additions & 1 deletion build_tools/cmake/iree_copts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ iree_select_compiler_opts(IREE_DEFAULT_COPTS
# Explicitly enable some additional warnings.
# Some of these aren't on by default, or under -Wall, or are subsets of
# warnings turned off above.
"-Wc++20-extensions" # Enable until we use C++20 across all compilers
#
# TODO(#16946): reenable -Wc++20-extensions.
# "-Wc++20-extensions" # Enable until we use C++20 across all compilers
"-Wctad-maybe-unsupported"
"-Wfloat-overflow-conversion"
"-Wfloat-zero-conversion"
Expand Down
1 change: 1 addition & 0 deletions compiler/plugins/input/StableHLO/Conversion/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TensorUtils",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:VectorDialect",
"@stablehlo//:broadcast_utils",
Expand Down
1 change: 1 addition & 0 deletions compiler/plugins/input/StableHLO/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ iree_cc_library(
MLIRSupport
MLIRTensorDialect
MLIRTensorUtils
MLIRTransformUtils
MLIRTransforms
MLIRVectorDialect
StablehloBroadcastUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:SparseTensorDialect",
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
"@stablehlo//:chlo_ops",
"@stablehlo//:stablehlo_ops",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ iree_cc_library(
MLIRSparseTensorDialect
MLIRSupport
MLIRTensorDialect
MLIRTransformUtils
MLIRTransforms
StablehloOps
PUBLIC
Expand Down
2 changes: 2 additions & 0 deletions compiler/plugins/input/TOSA/InputConversion/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:LinalgDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
],
)
Expand Down Expand Up @@ -78,6 +79,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:TosaToMLProgram",
"@llvm-project//mlir:TosaToSCF",
"@llvm-project//mlir:TosaToTensor",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
],
)
2 changes: 2 additions & 0 deletions compiler/plugins/input/TOSA/InputConversion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ iree_cc_library(
MLIRLinalgDialect
MLIRPass
MLIRTensorDialect
MLIRTransformUtils
MLIRTransforms
iree::compiler::Dialect::LinalgExt::IR
PUBLIC
Expand Down Expand Up @@ -67,6 +68,7 @@ iree_cc_library(
MLIRTosaToMLProgram
MLIRTosaToSCF
MLIRTosaToTensor
MLIRTransformUtils
MLIRTransforms
iree::compiler::Dialect::LinalgExt::IR
iree::compiler::InputConversion::Common
Expand Down
2 changes: 1 addition & 1 deletion compiler/plugins/target/MetalSPIRV/MetalSPIRVTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class MetalSPIRVTargetBackend : public TargetBackend {
if (variantOp.isExternal())
return;

buildSPIRVCodegenPassPipeline(passManager, /*enableFastMath=*/false);
buildSPIRVCodegenPassPipeline(passManager);
}

LogicalResult serializeExecutable(const SerializationOptions &serOptions,
Expand Down
2 changes: 1 addition & 1 deletion compiler/plugins/target/VulkanSPIRV/VulkanSPIRVTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class VulkanSPIRVTargetBackend : public TargetBackend {
if (variantOp.isExternal())
return;

buildSPIRVCodegenPassPipeline(passManager, /*enableFastMath=*/false);
buildSPIRVCodegenPassPipeline(passManager);
}

void buildLinkingPassPipeline(OpPassManager &passManager) override {
Expand Down
25 changes: 9 additions & 16 deletions compiler/plugins/target/WebGPUSPIRV/WebGPUSPIRVTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,15 @@ class WebGPUSPIRVTargetBackend : public TargetBackend {
passManager.nest<ModuleOp>().nest<func::FuncOp>().addPass(
createWGSLReplacePushConstantsPass());

// From WGSL spec, "Floating Point Evaluation"
// (https://www.w3.org/TR/WGSL/#floating-point-evaluation):
// - Implementations may assume that NaNs and infinities are not present at
// runtime.
// - In such an implementation, when an evaluation would produce an
// infinity or a NaN, an undefined value of the target type is produced
// instead.
// So WebGPU effectively assumes fast math mode. We also don't have reliable
// ways to check whether a floating point number is NaN or infinity.
// Therefore, just let the SPIR-V CodeGen to avoid generating guards w.r.t.
// NaN and infinity.
buildSPIRVCodegenPassPipeline(passManager, /*enableFastMath=*/true);

// WGSL does not support extended multiplication:
// https://github.com/gpuweb/gpuweb/issues/1565. Make sure to lower it to
// regular multiplication before we convert SPIR-V to WGSL.
buildSPIRVCodegenPassPipeline(passManager);

// Prepare SPIR-V for WebGPU by expanding or removing unsupported ops.
// For example,
// * WGSL does not support extended multiplication:
// https://github.com/gpuweb/gpuweb/issues/1565, so we lower to
// regular multiplication
// * WGSL does not support NaN or infinities:
// https://www.w3.org/TR/WGSL/#floating-point-evaluation
passManager.nest<ModuleOp>().nest<spirv::ModuleOp>().addPass(
spirv::createSPIRVWebGPUPreparePass());
}
Expand Down
1 change: 1 addition & 0 deletions compiler/src/iree/compiler/API/Internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ iree_compiler_cc_library(
"//compiler/src/iree/compiler/Reducer:iree_reduce_lib",
"//compiler/src/iree/compiler/Tools:init_passes_and_dialects",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:BytecodeWriter",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Parser",
"@llvm-project//mlir:Pass",
Expand Down
1 change: 1 addition & 0 deletions compiler/src/iree/compiler/API/Internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ iree_cc_library(
"IREEReduceToolEntryPoint.cpp"
DEPS
LLVMSupport
MLIRBytecodeWriter
MLIRIR
MLIRParser
MLIRPass
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/iree/compiler/Codegen/Common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:LinalgTransforms",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
],
)
Expand Down Expand Up @@ -190,6 +191,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:TensorUtils",
"@llvm-project//mlir:TilingInterface",
"@llvm-project//mlir:TransformDialect",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:ValueBoundsOpInterface",
"@llvm-project//mlir:VectorDialect",
Expand Down Expand Up @@ -259,6 +261,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:SCFTransforms",
"@llvm-project//mlir:TensorTransforms",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:VectorTransforms",
# Other Stuff
"//compiler/src/iree/compiler/Utils",
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/iree/compiler/Codegen/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ iree_cc_library(
MLIRLinalgTransforms
MLIRMemRefDialect
MLIRPass
MLIRTransformUtils
MLIRTransforms
iree::compiler::Codegen::Dialect::Codegen::IR::IREECodegenDialect
iree::compiler::Dialect::HAL::IR
Expand Down Expand Up @@ -157,6 +158,7 @@ iree_cc_library(
MLIRTensorUtils
MLIRTilingInterface
MLIRTransformDialect
MLIRTransformUtils
MLIRTransforms
MLIRValueBoundsOpInterface
MLIRVectorDialect
Expand Down Expand Up @@ -230,6 +232,7 @@ iree_cc_library(
MLIRTransformDialect
MLIRTransformDialectTransforms
MLIRTransformLoopExtension
MLIRTransformUtils
MLIRTransforms
MLIRVectorDialect
MLIRVectorTransformOps
Expand Down
1 change: 1 addition & 0 deletions compiler/src/iree/compiler/Codegen/Common/CPU/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TensorTransforms",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:VectorDialect",
"@llvm-project//mlir:VectorToSCF",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ iree_cc_library(
MLIRSupport
MLIRTensorDialect
MLIRTensorTransforms
MLIRTransformUtils
MLIRTransforms
MLIRVectorDialect
MLIRVectorToSCF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ class CPULowerToUKernelsPass

void runOnOperation() override;

LogicalResult initializeOptions(StringRef options) override {
if (failed(Pass::initializeOptions(options))) {
LogicalResult initializeOptions(
StringRef options,
function_ref<LogicalResult(const Twine &)> errorHandler) override {
if (failed(Pass::initializeOptions(options, errorHandler))) {
return failure();
}
// This option defaults to `true` both in Passes.td and in C++ code.
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/iree/compiler/Codegen/Common/GPU/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:NVGPUDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
],
)
Expand Down Expand Up @@ -122,6 +123,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TensorTransforms",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:VectorDialect",
"@llvm-project//mlir:VectorToSCF",
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/iree/compiler/Codegen/Common/GPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ iree_cc_library(
MLIRMemRefDialect
MLIRNVGPUDialect
MLIRPass
MLIRTransformUtils
MLIRTransforms
iree::compiler::Codegen::Dialect::Codegen::IR::IREECodegenDialect
iree::compiler::Dialect::HAL::IR
Expand Down Expand Up @@ -106,6 +107,7 @@ iree_cc_library(
MLIRSupport
MLIRTensorDialect
MLIRTensorTransforms
MLIRTransformUtils
MLIRTransforms
MLIRVectorDialect
MLIRVectorToSCF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,10 @@ struct ReorderWorkgroupsPass final
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<affine::AffineDialect>();
}
LogicalResult initializeOptions(StringRef options) override {
if (failed(Pass::initializeOptions(options))) {
LogicalResult initializeOptions(
StringRef options,
function_ref<LogicalResult(const Twine &)> errorHandler) override {
if (failed(Pass::initializeOptions(options, errorHandler))) {
return failure();
}
logSwizzleTile = logTile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ struct OptimizeVectorTransferPass
LDBG("after erasing unused allocs and stores\n" << funcOp);
}

LogicalResult initializeOptions(StringRef options) override {
if (failed(Pass::initializeOptions(options))) {
LogicalResult initializeOptions(
StringRef options,
function_ref<LogicalResult(const Twine &)> errorHandler) override {
if (failed(Pass::initializeOptions(options, errorHandler))) {
return failure();
}
// `flatten` may have been set to `true` in the constructor already.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:TensorTransforms",
"@llvm-project//mlir:TransformDialect",
"@llvm-project//mlir:TransformDialectInterfaces",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:VectorDialect",
"@llvm-project//mlir:VectorToGPU",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ iree_cc_library(
MLIRTensorTransforms
MLIRTransformDialect
MLIRTransformDialectInterfaces
MLIRTransformUtils
MLIRTransforms
MLIRVectorDialect
MLIRVectorToGPU
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/iree/compiler/Codegen/LLVMCPU/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:LinalgTransforms",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
],
)
Expand Down Expand Up @@ -158,6 +159,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:TosaDialect",
"@llvm-project//mlir:TosaToArith",
"@llvm-project//mlir:TransformDialect",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:ValueBoundsOpInterface",
"@llvm-project//mlir:VectorDialect",
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/iree/compiler/Codegen/LLVMCPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ iree_cc_library(
MLIRLinalgTransforms
MLIRMemRefDialect
MLIRPass
MLIRTransformUtils
MLIRTransforms
iree::compiler::Codegen::Dialect::Codegen::IR::IREECodegenDialect
iree::compiler::Dialect::HAL::IR
Expand Down Expand Up @@ -131,6 +132,7 @@ iree_cc_library(
MLIRTosaDialect
MLIRTosaToArith
MLIRTransformDialect
MLIRTransformUtils
MLIRTransforms
MLIRValueBoundsOpInterface
MLIRVectorDialect
Expand Down
1 change: 1 addition & 0 deletions compiler/src/iree/compiler/Codegen/LLVMGPU/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:TransformDialect",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:ValueBoundsOpInterface",
"@llvm-project//mlir:VectorDialect",
Expand Down
1 change: 1 addition & 0 deletions compiler/src/iree/compiler/Codegen/LLVMGPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ iree_cc_library(
MLIRSupport
MLIRTensorDialect
MLIRTransformDialect
MLIRTransformUtils
MLIRTransforms
MLIRValueBoundsOpInterface
MLIRVectorDialect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:ArithDialect",
"@llvm-project//mlir:BufferizationDialect",
"@llvm-project//mlir:BufferizationInterfaces",
"@llvm-project//mlir:BytecodeOpInterface",
"@llvm-project//mlir:DialectUtils",
"@llvm-project//mlir:FuncDialect",
"@llvm-project//mlir:FunctionInterfaces",
Expand All @@ -89,6 +90,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:TensorTransformOps",
"@llvm-project//mlir:TransformDialect",
"@llvm-project//mlir:TransformDialectInterfaces",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:VectorDialect",
"@llvm-project//mlir:VectorToGPU",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ iree_cc_library(
MLIRAffineDialect
MLIRArithDialect
MLIRBufferizationDialect
MLIRBytecodeOpInterface
MLIRFuncDialect
MLIRFunctionInterfaces
MLIRGPUDialect
Expand All @@ -55,6 +56,7 @@ iree_cc_library(
MLIRTensorTransformOps
MLIRTransformDialect
MLIRTransformDialectInterfaces
MLIRTransformUtils
MLIRTransforms
MLIRVectorDialect
MLIRVectorToGPU
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/iree/compiler/Codegen/SPIRV/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:LinalgTransforms",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
],
)
Expand Down Expand Up @@ -151,6 +152,7 @@ iree_compiler_cc_library(
"@llvm-project//mlir:TosaDialect",
"@llvm-project//mlir:TosaToArith",
"@llvm-project//mlir:TransformDialect",
"@llvm-project//mlir:TransformUtils",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:VectorDialect",
"@llvm-project//mlir:VectorInterfaces",
Expand Down
Loading

0 comments on commit 3fa9fbd

Please sign in to comment.