Integrate LLVM to llvm/llvm-project@6be022066fd2 (#25045)
Adapted to change of ROCDL "wave per eu" attributes type from int to
string in LLVM commit 4d5db577f969 [mlir][ROCDL][AMDGPU] Support string
waves_per_eu for min,max occupancy range (#225663)
The TOSA compliance table has grown beyond what MSVC can support on the
stack.
Apparently, the function size / stack size has been an issue before, see
e.g.:
9e69e851a1f8 [NFC][mlir][tosa] Use optnone for compliance initialization
under ASan (#229292)
1e9bc138d8f3 [mlir][Tosa] Optimize compliance initialization for size to
improve build time (NFC) (#222791)
This change currently adds an experimental mitigation to the LLVM fork
by splitting up the initialization.
Claude Code has been used to find the LLVM commits related to the issued
and adapt the IREE side code. The changes have been reviewed manually.
Signed-off-by: Stefan Schuermans <schuermans@roofline.ai>
diff --git a/build_tools/bazel/build_defs.oss.bzl b/build_tools/bazel/build_defs.oss.bzl
index f908471..7a446a2 100644
--- a/build_tools/bazel/build_defs.oss.bzl
+++ b/build_tools/bazel/build_defs.oss.bzl
@@ -23,6 +23,17 @@
iree_compiler_cc_fuzz = _iree_compiler_cc_fuzz
iree_runtime_cc_fuzz = _iree_runtime_cc_fuzz
+# Link options for executables that run the compiler pipelines in-process.
+# Windows reserves only 1 MB of stack by default, which is not enough for some
+# compiler paths (e.g. the TOSA profile compliance table initialization in
+# TosaValidation). Reserve 10 MB like LLVM does for its own tools.
+# Keep in sync with IREE_COMPILER_TOOL_LINKOPTS in
+# build_tools/cmake/iree_copts.cmake.
+IREE_COMPILER_TOOL_LINKOPTS = select({
+ Label("//build_tools/bazel:iree_is_windows"): ["/STACK:10000000"],
+ "//conditions:default": [],
+})
+
def defaulting_select(selector):
"""Pass through to select() with special semantics when converting to CMake.
diff --git a/build_tools/cmake/iree_copts.cmake b/build_tools/cmake/iree_copts.cmake
index 2aefc44..ded173e 100644
--- a/build_tools/cmake/iree_copts.cmake
+++ b/build_tools/cmake/iree_copts.cmake
@@ -429,6 +429,17 @@
"-pdbpagesize:32768"
)
+# Link options for executables that run the compiler pipelines in-process.
+# Windows reserves only 1 MB of stack by default, which is not enough for some
+# compiler paths (e.g. the TOSA profile compliance table initialization in
+# TosaValidation). Reserve 10 MB like LLVM does for its own tools.
+# Keep in sync with IREE_COMPILER_TOOL_LINKOPTS in
+# build_tools/bazel/build_defs.oss.bzl.
+iree_select_compiler_opts(IREE_COMPILER_TOOL_LINKOPTS
+ MSVC_OR_CLANG_CL
+ "LINKER:/STACK:10000000"
+)
+
if(EMSCRIPTEN AND IREE_EXTERNAL_WEBGPU_HAL_DRIVER_FOUND)
iree_select_compiler_opts(IREE_DEFAULT_LINKOPTS
ALL
diff --git a/compiler/src/iree/compiler/Codegen/LLVMGPU/ROCDLAnnotateKernelForTranslation.cpp b/compiler/src/iree/compiler/Codegen/LLVMGPU/ROCDLAnnotateKernelForTranslation.cpp
index c3ccf1f..1bdb238 100644
--- a/compiler/src/iree/compiler/Codegen/LLVMGPU/ROCDLAnnotateKernelForTranslation.cpp
+++ b/compiler/src/iree/compiler/Codegen/LLVMGPU/ROCDLAnnotateKernelForTranslation.cpp
@@ -99,7 +99,8 @@
if (targetAttr && targetAttr.getConfiguration()) {
if (IntegerAttr attr =
getConfigWavesPerEuAttr(targetAttr.getConfiguration())) {
- rocdlDialect->getWavesPerEuAttrHelper().setAttr(funcOp, attr);
+ rocdlDialect->getWavesPerEuAttrHelper().setAttr(
+ funcOp, builder.getStringAttr(Twine(attr.getInt())));
}
if (IREE::Codegen::DenormalFpMathAttr attr =
getConfigDenormalFpMathF32Attr(targetAttr.getConfiguration());
diff --git a/third_party/llvm-project b/third_party/llvm-project
index 32d702e..6be0220 160000
--- a/third_party/llvm-project
+++ b/third_party/llvm-project
@@ -1 +1 @@
-Subproject commit 32d702efa29d0fdd02cff7b79dea8fdbbcf059d4
+Subproject commit 6be022066fd2a5139fc094d90f1b59795b2fd00f
diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel
index 078a07f..c89d364 100644
--- a/tools/BUILD.bazel
+++ b/tools/BUILD.bazel
@@ -15,7 +15,7 @@
# platforms (e.g. Android), so they are tagged "hostonly".
load("@rules_cc//cc:defs.bzl", "cc_binary")
-load("//build_tools/bazel:build_defs.oss.bzl", "iree_compiler_cc_binary", "iree_runtime_cc_binary")
+load("//build_tools/bazel:build_defs.oss.bzl", "IREE_COMPILER_TOOL_LINKOPTS", "iree_compiler_cc_binary", "iree_runtime_cc_binary")
package(
default_visibility = ["//visibility:public"],
@@ -254,6 +254,7 @@
iree_compiler_cc_binary(
name = "iree-opt",
srcs = ["iree-opt-main.cc"],
+ linkopts = IREE_COMPILER_TOOL_LINKOPTS,
tags = ["hostonly"],
deps = [
"//compiler/bindings/c:headers",
@@ -264,6 +265,7 @@
iree_compiler_cc_binary(
name = "iree-mlir-lsp-server",
srcs = ["iree-mlir-lsp-server.cc"],
+ linkopts = IREE_COMPILER_TOOL_LINKOPTS,
deps = [
"//compiler/bindings/c:headers",
"//compiler/src/iree/compiler/API:Impl",
@@ -276,6 +278,7 @@
cc_binary(
name = "iree-run-mlir",
srcs = ["iree-run-mlir-main.cc"],
+ linkopts = IREE_COMPILER_TOOL_LINKOPTS,
tags = ["hostonly"],
deps = [
"//compiler/bindings/c:headers",
@@ -357,6 +360,7 @@
iree_compiler_cc_binary(
name = "iree-compile",
srcs = ["iree-compile-main.cc"],
+ linkopts = IREE_COMPILER_TOOL_LINKOPTS,
tags = ["hostonly"],
deps = [
"//compiler/bindings/c:headers",
@@ -377,6 +381,7 @@
iree_compiler_cc_binary(
name = "iree-reduce",
srcs = ["iree-reduce.cc"],
+ linkopts = IREE_COMPILER_TOOL_LINKOPTS,
tags = ["hostonly"],
deps = [
"//compiler/bindings/c:headers",
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 21cc7bd..dd6a3ad 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -476,6 +476,8 @@
iree-compile
SRCS
"iree-compile-main.cc"
+ LINKOPTS
+ ${IREE_COMPILER_TOOL_LINKOPTS}
DEPS
iree::compiler::bindings::c::headers
iree::compiler::API::Impl
@@ -491,6 +493,8 @@
iree-reduce
SRCS
"iree-reduce.cc"
+ LINKOPTS
+ ${IREE_COMPILER_TOOL_LINKOPTS}
DEPS
iree::compiler::bindings::c::headers
iree::compiler::API::Impl
@@ -537,6 +541,8 @@
iree-opt
SRCS
"iree-opt-main.cc"
+ LINKOPTS
+ ${IREE_COMPILER_TOOL_LINKOPTS}
DEPS
iree::compiler::bindings::c::headers
iree::compiler::API::Impl
@@ -552,6 +558,8 @@
iree-mlir-lsp-server
SRCS
"iree-mlir-lsp-server.cc"
+ LINKOPTS
+ ${IREE_COMPILER_TOOL_LINKOPTS}
DEPS
iree::compiler::bindings::c::headers
iree::compiler::API::Impl
@@ -564,6 +572,8 @@
iree-run-mlir
SRCS
"iree-run-mlir-main.cc"
+ LINKOPTS
+ ${IREE_COMPILER_TOOL_LINKOPTS}
DEPS
iree::base
iree::base::tooling::flags