Merge google -> main (#2333)

* Control timeline semaphore emulation at runtime, remove extension layer
* Add shape constraints to XLA CHLO-LHLO lowering
* bazel_to_cmake fixes
* LLVM integrates
diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml
index 13581ea..16ecca0 100644
--- a/.github/workflows/publish_docs.yml
+++ b/.github/workflows/publish_docs.yml
@@ -26,6 +26,10 @@
     env:
       IREE_DOC_BUILD_DIR: build-docs
     steps:
+      - name: Setup Bazel
+        uses: abhinavsingh/setup-bazel@v3
+        with:
+          version: 2.1.0
       - name: Checking out repository
         uses: actions/checkout@v2
         with:
diff --git a/.gitmodules b/.gitmodules
index 2cee5eb..13d12e9 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -38,9 +38,6 @@
 [submodule "third_party/dear_imgui"]
 	path = third_party/dear_imgui
 	url = https://github.com/ocornut/imgui.git
-[submodule "third_party/vulkan_extensionlayer"]
-	path = third_party/vulkan_extensionlayer
-	url = https://github.com/KhronosGroup/Vulkan-ExtensionLayer
 [submodule "third_party/ruy"]
 	path = third_party/ruy
 	url = https://github.com/google/ruy
diff --git a/.yamllint.yml b/.yamllint.yml
index a52bc13..51b64c3 100644
--- a/.yamllint.yml
+++ b/.yamllint.yml
@@ -1,3 +1,17 @@
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 extends: default
 
 rules:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 004bed5..d8cdbaa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -234,7 +234,7 @@
 # MLIR/LLVM Dependency
 # We treat the LLVM dependency specially because we support several different
 # ways to use it:
-#   - Bundled (default): a source dependency directly on the 
+#   - Bundled (default): a source dependency directly on the
 #     third_party/llvm-project submodule.
 #   - External: An external (source or installed) dependency on LLVM.
 #   - Provided: When IREE is used as a sub-project, it is assumed that the LLVM
@@ -243,7 +243,7 @@
 
 
 # Adds bundled projects that must be included after the LLVM directory has
-# been added and within the scope of its settings (i.e. build type override, 
+# been added and within the scope of its settings (i.e. build type override,
 # etc).
 function(add_bundled_mlir_dependent_projects)
   if(${IREE_ENABLE_EMITC})
@@ -330,9 +330,7 @@
 add_subdirectory(third_party/abseil-cpp EXCLUDE_FROM_ALL)
 add_subdirectory(third_party/flatbuffers EXCLUDE_FROM_ALL)
 add_subdirectory(third_party/vulkan_headers EXCLUDE_FROM_ALL)
-add_subdirectory(third_party/vulkan_extensionlayer EXCLUDE_FROM_ALL)
 add_subdirectory(build_tools/third_party/renderdoc_api EXCLUDE_FROM_ALL)
-add_subdirectory(build_tools/third_party/vulkan_extensionlayer EXCLUDE_FROM_ALL)
 
 if(CMAKE_CROSSCOMPILING)
   # We need flatc to generate some source code. When cross-compiling, we need
diff --git a/SUBMODULE_VERSIONS b/SUBMODULE_VERSIONS
index b9f7575..9a89b24 100644
--- a/SUBMODULE_VERSIONS
+++ b/SUBMODULE_VERSIONS
@@ -3,7 +3,7 @@
 4c13807b7d43ff0946b7ffea0ae3aee9e611d778 third_party/dear_imgui
 a5d9d0f7d368054fd1691aedf1db4116efcc233e third_party/flatbuffers
 f2fb48c3b3d79a75a88a99fba6576b25d42ec528 third_party/googletest
-f0bab7875e78e01c149d12302dcc4b6d4c43e25c third_party/llvm-project
+1becd298b82ed2f1a8ba5e61c5ad2ce7fe32d812 third_party/llvm-project
 17b12a4481daa150e2d1ea3ada086b551b856707 third_party/marl
 67f3ccebee84f3488b46a8d3ac005178c52ff264 third_party/mlir-emitc
 80d452484c5409444b0ec19383faa84bb7a4d351 third_party/pybind11
@@ -13,6 +13,5 @@
 57eb48aed36160c4876bc8310d9ca84d42ee9e2a third_party/swiftshader
 b3319125a036aea6b7bbc0d1c50753e7be73be27 third_party/tensorflow
 864d86e8b6d21449474db5e9313dbff90aa9c24f third_party/tracy
-8a457f8552d8d47ce3a96ed80a714ff6396f8ad8 third_party/vulkan_extensionlayer
 9bd3f561bcee3f01d22912de10bb07ce4e23d378 third_party/vulkan_headers
 909f36b714c9239ee0b112a321220213a474ba53 third_party/vulkan_memory_allocator
diff --git a/WORKSPACE b/WORKSPACE
index 3e26af0..9663fd4 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -177,12 +177,6 @@
 )
 
 maybe(new_local_repository,
-    name = "vulkan_extensionlayer",
-    path = "third_party/vulkan_extensionlayer",
-    build_file = "build_tools/third_party/vulkan_extensionlayer/BUILD.overlay",
-)
-
-maybe(new_local_repository,
     name = "vulkan_memory_allocator",
     path = "third_party/vulkan_memory_allocator",
     build_file = "build_tools/third_party/vulkan_memory_allocator/BUILD.overlay",
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
index edf6b10..00ee03c 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
@@ -39,6 +39,7 @@
     "@llvm-project//mlir:LLVMTransforms": ["MLIRStandardToLLVM"],
     "@llvm-project//mlir:SCFToGPUPass": ["MLIRSCFToGPU"],
     "@llvm-project//mlir:SCFDialect": ["MLIRSCF"],
+    "@llvm-project//mlir:ShapeTransforms": ["MLIRShapeOpsTransforms"],
     "@llvm-project//mlir:SideEffects": ["MLIRSideEffectInterfaces"],
     "@llvm-project//mlir:SPIRVDialect": ["MLIRSPIRV"],
     "@llvm-project//mlir:SPIRVLowering": ["MLIRSPIRV", "MLIRSPIRVTransforms"],
diff --git a/build_tools/cmake/build_docs.sh b/build_tools/cmake/build_docs.sh
index 3c5ce15..d4a3c84 100755
--- a/build_tools/cmake/build_docs.sh
+++ b/build_tools/cmake/build_docs.sh
@@ -51,7 +51,9 @@
 
 # Update op_coverage.md
 scripts/update_op_coverage.py ${BUILD_DIR}
-scripts/update_e2e_coverage.py ${BUILD_DIR}
+
+# Update e2e_coverage.md
+PYTHON_BIN=`which python3` scripts/update_e2e_coverage.py ${BUILD_DIR}
 
 # Copy a curated list of docs to publish. This is expected to cover all docs
 # under docs/ after they are refreshed.
diff --git a/build_tools/third_party/swiftshader/build_vk_swiftshader.sh b/build_tools/third_party/swiftshader/build_vk_swiftshader.sh
index 9f93b01..f6692da 100644
--- a/build_tools/third_party/swiftshader/build_vk_swiftshader.sh
+++ b/build_tools/third_party/swiftshader/build_vk_swiftshader.sh
@@ -25,7 +25,7 @@
 # path of the corresponding vk_swiftshader_icd.json manifest file so the Vulkan
 # loader on your system loads it, for example:
 #   Windows
-#   $ set VK_ICD_FILENAMES=C:\dev\iree\build-swiftshader\Release\vk_swiftshader_icd_windows.json
+#   $ set VK_ICD_FILENAMES=C:\dev\iree\build-swiftshader\Windows\vk_swiftshader_icd.json
 #
 #   Linux
 #   $ VK_ICD_FILENAMES=/dev/iree/build-swiftshader/Linux/vk_swiftshader_icd.json
@@ -41,23 +41,6 @@
     exit 1
 fi
 
-if [[ "$OSTYPE" == "linux-gnu" ]]; then
-    PLATFORM_ARGS=""
-elif [[ "$OSTYPE" == "darwin" ]]; then
-    # TODO(scotttodd): Mac OSX args?
-    PLATFORM_ARGS=""
-elif [[ "$OSTYPE" == "msys" ]] || \
-     [[ "$OSTYPE" == "cygwin" ]] || \
-     [[ "$OSTYPE" == "win32" ]]; then
-    # Some sort of Windows platform.
-    PLATFORM_ARGS="-A x64 -Thost=x64"
-else
-    >&2 echo "*******************"
-    >&2 echo "* Unknown OS type *"
-    >&2 echo "*******************"
-    exit 1
-fi
-
 # Generate build system in build-swiftshader/ for third_party/swiftshader/.
 #
 # Options:
@@ -66,7 +49,6 @@
 #   - Don't build samples or tests
 cmake -B build-swiftshader/ \
     -GNinja \
-    $PLATFORM_ARGS \
     -DSWIFTSHADER_BUILD_VULKAN=ON \
     -DSWIFTSHADER_BUILD_EGL=OFF \
     -DSWIFTSHADER_BUILD_GLESv2=OFF \
@@ -80,12 +62,4 @@
 
 # Outputs if successful:
 #   Linux:   build-swiftshader/Linux/libvk_swiftshader.so
-#   Windows: build-swiftshader/Release/vk_swiftshader.dll
-
-# On Windows, copy the ICD manifest file into the build directory, so relative
-# paths work. Linux already writes vk_swiftshader_icd.json into the build dir.
-if [[ "$OSTYPE" == "msys" ]] || \
-   [[ "$OSTYPE" == "cygwin" ]] || \
-   [[ "$OSTYPE" == "win32" ]]; then
-    cp build_tools/third_party/swiftshader/vk_swiftshader_icd_windows.json build-swiftshader/Release/
-fi
+#   Windows: build-swiftshader/Windows/vk_swiftshader.dll
diff --git a/build_tools/third_party/swiftshader/vk_swiftshader_icd_windows.json b/build_tools/third_party/swiftshader/vk_swiftshader_icd_windows.json
deleted file mode 100644
index 198828b..0000000
--- a/build_tools/third_party/swiftshader/vk_swiftshader_icd_windows.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{

-  "file_format_version": "1.0.0",

-  "ICD": {

-    "library_path": ".\\vk_swiftshader.dll",

-    "api_version": "1.0.5"

-  }

-}

diff --git a/build_tools/third_party/tensorflow/tensorflow/compiler/mlir/xla/CMakeLists.txt b/build_tools/third_party/tensorflow/tensorflow/compiler/mlir/xla/CMakeLists.txt
index dc40414..ee7bf63 100644
--- a/build_tools/third_party/tensorflow/tensorflow/compiler/mlir/xla/CMakeLists.txt
+++ b/build_tools/third_party/tensorflow/tensorflow/compiler/mlir/xla/CMakeLists.txt
@@ -82,6 +82,7 @@
     MLIRLinalgOps
     MLIRPass
     MLIRShape
+    MLIRShapeOpsTransforms
     MLIRTransformUtils
   PUBLIC
 )
diff --git a/build_tools/third_party/vulkan_extensionlayer/BUILD.overlay b/build_tools/third_party/vulkan_extensionlayer/BUILD.overlay
deleted file mode 100644
index 6b22910..0000000
--- a/build_tools/third_party/vulkan_extensionlayer/BUILD.overlay
+++ /dev/null
@@ -1,91 +0,0 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-load("@iree_core//build_tools/bazel:template_rule.bzl", "template_rule")
-
-package(default_visibility = ["//visibility:public"])
-
-COMMON_COPTS = [
-    "-fno-builtin-memcmp",
-    "-fno-strict-aliasing",
-    "-fvisibility=hidden",
-    "-Wall",
-    "-Wextra",
-    "-Wno-implicit-fallthrough",
-    "-Wno-missing-field-initializers",
-    "-Wno-nonnull",
-    "-Wno-sign-compare",
-    "-Wno-string-conversion",
-    "-Wno-unused-const-variable",
-    "-Wno-unused-function",
-    "-Wno-unused-parameter",
-    "-Wno-unused-private-field",
-    "-Wpointer-arith",
-]
-
-COPTS = COMMON_COPTS + [
-    "-std=c++11",
-    "-fno-rtti",
-]
-
-C_COPTS = COMMON_COPTS + [
-    "-std=c99",
-    # Require a recent enough POSIX source to get # pthead_condattr_setclock.
-    "-D_POSIX_C_SOURCE=200112",
-]
-
-LINKOPTS = [
-    "-Wl,-Bsymbolic,--exclude-libs,ALL",
-    # We ignore the -Wl,--version-script=... option from upstream
-]
-
-cc_library(
-    name = "hash_table",
-    srcs = [
-        "layers/hash_table.cpp",
-        "layers/hash_table.h",
-    ],
-    copts = COPTS,
-)
-
-cc_binary(
-    name = "libVkLayer_khronos_timeline_semaphore.so",
-    srcs = [
-        "layers/hash_table.h",
-        "layers/list.h",
-        "layers/timeline_semaphore.c",
-        "layers/vk_alloc.h",
-        "layers/vk_util.h",
-    ],
-    copts = C_COPTS,
-    linkopts = LINKOPTS,
-    linkshared = 1,
-    deps = [
-        ":hash_table",
-        "@iree_vulkan_headers//:vulkan_headers",
-    ],
-)
-
-# TODO(scotttodd): Fetch VK_VERSION dynamically
-#   CMake: `VK_VERSION=1.1.${vk_header_version}`
-#          (regex match on vulkan_core.h from VulkanHeaders)
-template_rule(
-    name = "VkLayer_khronos_timeline_semaphore_json",
-    src = "layers/json/VkLayer_khronos_timeline_semaphore.json.in",
-    out = "VkLayer_khronos_timeline_semaphore.json",
-    substitutions = {
-        "@RELATIVE_LAYER_BINARY@": "./libVkLayer_khronos_timeline_semaphore.so",
-        "@VK_VERSION@": "1.1.133",
-    }
-)
diff --git a/build_tools/third_party/vulkan_extensionlayer/CMakeLists.txt b/build_tools/third_party/vulkan_extensionlayer/CMakeLists.txt
deleted file mode 100644
index 31ee280..0000000
--- a/build_tools/third_party/vulkan_extensionlayer/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set(_NAME "vk_layer_khronos_timeline_semaphore")
-
-add_custom_target(${_NAME})
-
-if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
-  # Polyfill layer does not build on Windows.
-else()
-  iree_add_data_dependencies(
-    NAME
-      ${_NAME}
-    DATA
-      VkLayer_khronos_timeline_semaphore
-      VkLayer_khronos_timeline_semaphore-json
-  )
-endif()
diff --git a/docs/GetStarted/getting_started_linux_vulkan.md b/docs/GetStarted/getting_started_linux_vulkan.md
index 924f123..9ee8c61 100644
--- a/docs/GetStarted/getting_started_linux_vulkan.md
+++ b/docs/GetStarted/getting_started_linux_vulkan.md
@@ -24,11 +24,9 @@
 using [SwiftShader](https://swiftshader.googlesource.com/SwiftShader/) (a high
 performance CPU-based implementation of Vulkan).
 
-Vulkan API version > 1.2 is recommended where available. The
-`VK_KHR_timeline_semaphore` extension (part of Vulkan 1.2) is required, and the
-[Vulkan-ExtensionLayer](https://github.com/KhronosGroup/Vulkan-ExtensionLayer)
-project can be used to enable it for drivers (like SwiftShader) without native
-support.
+Vulkan drivers implementing API version >= 1.2 are recommended. IREE requires
+the `VK_KHR_timeline_semaphore` extension (part of Vulkan 1.2), though it is
+able to emulate it, with performance costs, as necessary.
 
 ## Vulkan Setup
 
@@ -97,39 +95,6 @@
 $ export VK_ICD_FILENAMES=$PWD/build-swiftshader/Linux/vk_swiftshader_icd.json
 ```
 
-### Setting up Vulkan-ExtensionLayer
-
-If you are missing support for `VK_KHR_timeline_semaphore`, setup the extension
-layer.
-
-Build:
-
-```shell
-# -- CMake --
-$ cmake --build build/ --target vk_layer_khronos_timeline_semaphore
-
-# -- Bazel --
-$ bazel build @vulkan_extensionlayer//:libVkLayer_khronos_timeline_semaphore.so @vulkan_extensionlayer//:VkLayer_khronos_timeline_semaphore_json
-```
-
-You should then also set the `VK_LAYER_PATH` environment variable to include the
-path to the built layer:
-
-```shell
-# -- CMake --
-$ export VK_LAYER_PATH=$PWD/build/third_party/vulkan_extensionlayer/layers/:$VK_LAYER_PATH
-
-# -- Bazel --
-$ export VK_LAYER_PATH=$PWD/bazel-bin/external/vulkan_extensionlayer/:$VK_LAYER_PATH
-```
-
-### Setting up the Vulkan Loader
-
-IREE relies on the `VK_KHR_timeline_semaphore` extension. The minimal loader
-version supporting this extenion is `1.1.124`. So if you see failures regarding
-timeline semaphore, in addtion to setting up the extension layer, please also
-check to make sure the loader is at a proper version.
-
 ### Support in Bazel Tests
 
 Bazel tests run in a sandbox, which environment variables may be forwarded to
@@ -140,7 +105,6 @@
 test --test_env="LD_LIBRARY_PATH={PATH_TO_VULKAN_SDK}/x86_64/lib/"
 test --test_env="LD_PRELOAD=libvulkan.so.1"
 test --test_env="VK_ICD_FILENAMES={PATH_TO_IREE}/build-swiftshader/Linux/vk_swiftshader_icd.json"
-test --test_env="VK_LAYER_PATH=$VK_LAYER_PATH:{PATH_TO_IREE}/bazel-bin/external/vulkan_extensionlayer/"
 ```
 
 ## Using IREE's Vulkan Compiler Target and Runtime Driver
@@ -187,9 +151,3 @@
 # -- Bazel --
 $ bazel run iree/samples/vulkan:vulkan_inference_gui
 ```
-
-## What's next?
-
-More documentation coming soon...
-
-<!-- TODO(scotttodd): link to Vulkan debugging, developer guides -->
diff --git a/docs/GetStarted/getting_started_windows_vulkan.md b/docs/GetStarted/getting_started_windows_vulkan.md
index 83e369c..9ceee2a 100644
--- a/docs/GetStarted/getting_started_windows_vulkan.md
+++ b/docs/GetStarted/getting_started_windows_vulkan.md
@@ -22,13 +22,11 @@
 
 You must have a physical GPU with drivers supporting Vulkan. We support using
 [SwiftShader](https://swiftshader.googlesource.com/SwiftShader/) (a high
-performance CPU-based implementation of Vulkan) on platforms where the
-[Vulkan-ExtensionLayer](https://github.com/KhronosGroup/Vulkan-ExtensionLayer)
-project builds, but it does not currently
-[build on Windows](https://github.com/KhronosGroup/Vulkan-ExtensionLayer/issues/16).
+performance CPU-based implementation of Vulkan).
 
-Vulkan API version > 1.2 is recommended where available, though older versions
-with support for the `VK_KHR_timeline_semaphore` extension may also work.
+Vulkan drivers implementing API version >= 1.2 are recommended. IREE requires
+the `VK_KHR_timeline_semaphore` extension (part of Vulkan 1.2), though it is
+able to emulate it, with performance costs, as necessary.
 
 ## Vulkan Setup
 
@@ -74,23 +72,38 @@
 
 If these tests pass, you can skip down to the next section.
 
-### Setting up the Vulkan Loader
-
-IREE relies on the `VK_KHR_timeline_semaphore` extension. The minimal loader
-version supporting this extenion is `1.1.124`. So if you see failures regarding
-timeline semaphore, please also check to make sure the loader is at a proper
-version.
-
-<!--
 ### Setting up SwiftShader
 
-TODO(scotttodd): Document when SwiftShader supports `VK_KHR_timeline_semaphore`
-                 Or Vulkan-ExtensionLayer builds for Windows
+If your system lacks a physical GPU with compatible Vulkan drivers, or you just
+want to use a software driver for predictable performance, you can set up
+SwiftShader's Vulkan ICD (Installable Client Driver).
 
-### Setting up Vulkan-ExtensionLayer
+IREE has a
+[helper script](https://github.com/google/iree/blob/master/build_tools/third_party/swiftshader/build_vk_swiftshader.sh)
+for building SwiftShader from source using CMake:
 
-TODO(scotttodd): Document when Vulkan-ExtensionLayer builds for Windows
--->
+```shell
+$ bash build_tools/third_party/swiftshader/build_vk_swiftshader.sh
+```
+
+<!-- TODO(scotttodd): Steps to download prebuilt binaries when they exist -->
+
+After building, set the `VK_ICD_FILENAMES` environment variable so the Vulkan
+loader uses the ICD:
+
+```powershell
+> $env:VK_ICD_FILENAMES = Resolve-Path "build-swiftshader/Windows/vk_swiftshader_icd.json"
+```
+
+### Support in Bazel Tests
+
+Bazel tests run in a sandbox, which environment variables may be forwarded to
+using the `--test_env` flag. A user.bazelrc file using SwiftShader looks like
+this (substitute for the `{}` paths):
+
+```
+test --test_env="VK_ICD_FILENAMES={PATH_TO_IREE}\\build-swiftshader\\Windows\\vk_swiftshader_icd.json"
+```
 
 ## Using IREE's Vulkan Compiler Target and Runtime Driver
 
@@ -136,9 +149,3 @@
 # -- Bazel --
 > bazel run iree/samples/vulkan:vulkan_inference_gui
 ```
-
-## What's next?
-
-More documentation coming soon...
-
-<!-- TODO(scotttodd): link to Vulkan debugging, developer guides -->
diff --git a/integrations/tensorflow/compiler/BUILD b/integrations/tensorflow/compiler/BUILD
index bb37029..9856c4f 100644
--- a/integrations/tensorflow/compiler/BUILD
+++ b/integrations/tensorflow/compiler/BUILD
@@ -45,6 +45,7 @@
         "@llvm-project//mlir:IR",
         "@llvm-project//mlir:Pass",
         "@llvm-project//mlir:Shape",
+        "@llvm-project//mlir:ShapeTransforms",
         "@llvm-project//mlir:Support",
         "@llvm-project//mlir:TransformUtils",
         "@org_tensorflow//tensorflow/compiler/mlir/tensorflow",
diff --git a/integrations/tensorflow/compiler/Passes.cpp b/integrations/tensorflow/compiler/Passes.cpp
index d4f3744..b4b6c47 100644
--- a/integrations/tensorflow/compiler/Passes.cpp
+++ b/integrations/tensorflow/compiler/Passes.cpp
@@ -18,6 +18,7 @@
 #include "integrations/tensorflow/compiler/dialect/tf_tensorlist/conversion/convert_tf_to_tf_tensorlist.h"
 #include "iree/compiler/Dialect/Shape/Conversion/Passes.h"
 #include "iree/compiler/Dialect/Shape/Transforms/Passes.h"
+#include "mlir/Dialect/Shape/Transforms/Passes.h"
 #include "mlir/Pass/PassManager.h"
 #include "mlir/Pass/PassRegistry.h"
 #include "mlir/Transforms/Passes.h"
@@ -32,6 +33,9 @@
   // Lowering shape-related constructs.
   ////////////////////////////////////////////////////////////////////////////
   pm.addPass(Shape::createConvertHLOToShapePass());
+  // TODO(GH-2277): Lower HLO shape constraints instead of eliding them here.
+  pm.addPass(createRemoveShapeConstraintsPass());
+  pm.addPass(createCanonicalizerPass());
   pm.addPass(Shape::createConvertShapeToShapexPass());
   // Clean up trivial redundancies.
   pm.addPass(createCanonicalizerPass());
diff --git a/iree/compiler/Dialect/Flow/Transforms/BUILD b/iree/compiler/Dialect/Flow/Transforms/BUILD
index 184aab7..37e89f7 100644
--- a/iree/compiler/Dialect/Flow/Transforms/BUILD
+++ b/iree/compiler/Dialect/Flow/Transforms/BUILD
@@ -58,6 +58,7 @@
         "@llvm-project//mlir:Analysis",
         "@llvm-project//mlir:IR",
         "@llvm-project//mlir:Pass",
+        "@llvm-project//mlir:ShapeTransforms",
         "@llvm-project//mlir:StandardOps",
         "@llvm-project//mlir:Support",
         "@llvm-project//mlir:TransformUtils",
diff --git a/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt b/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
index 668b29a..568ec4f 100644
--- a/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
@@ -42,6 +42,7 @@
     MLIRAnalysis
     MLIRIR
     MLIRPass
+    MLIRShapeOpsTransforms
     MLIRStandardOps
     MLIRSupport
     MLIRTransformUtils
diff --git a/iree/compiler/Dialect/Flow/Transforms/Passes.cpp b/iree/compiler/Dialect/Flow/Transforms/Passes.cpp
index f2976de..8b332cb 100644
--- a/iree/compiler/Dialect/Flow/Transforms/Passes.cpp
+++ b/iree/compiler/Dialect/Flow/Transforms/Passes.cpp
@@ -18,6 +18,7 @@
 
 #include "iree/compiler/Dialect/Shape/Conversion/Passes.h"
 #include "iree/compiler/Dialect/Shape/Transforms/Passes.h"
+#include "mlir/Dialect/Shape/Transforms/Passes.h"
 #include "mlir/Pass/PassRegistry.h"
 #include "mlir/Transforms/Passes.h"
 #include "tensorflow/compiler/mlir/xla/transforms/passes.h"
@@ -41,6 +42,13 @@
   passManager.addNestedPass<FuncOp>(xla_hlo::createLegalizeControlFlowPass());
   passManager.addPass(createHLOPreprocessingPass());
 
+  // Run passes to remove shape constraints. HLO lowering inserts them, but they
+  // are not desired here.
+  //
+  // TODO(GH-2277): Lower HLO shape constraints instead of eliding them here.
+  passManager.addNestedPass<FuncOp>(createRemoveShapeConstraintsPass());
+  passManager.addNestedPass<FuncOp>(createCanonicalizerPass());
+
   // Convert `shape` dialect to `shapex` dialect.
   passManager.addPass(Shape::createConvertShapeToShapexPass());
 
diff --git a/iree/hal/vulkan/BUILD b/iree/hal/vulkan/BUILD
index d4c5753..153e52a 100644
--- a/iree/hal/vulkan/BUILD
+++ b/iree/hal/vulkan/BUILD
@@ -37,8 +37,6 @@
     },
 )
 
-# TODO(antiagainst): expose configuration for emulated timeline semaphore
-
 cc_library(
     name = "api",
     srcs = ["api.cc"],
diff --git a/iree/hal/vulkan/CMakeLists.txt b/iree/hal/vulkan/CMakeLists.txt
index 663437d..2129f6d 100644
--- a/iree/hal/vulkan/CMakeLists.txt
+++ b/iree/hal/vulkan/CMakeLists.txt
@@ -12,27 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# TODO(antiagainst): We should probably always compiling the emulation in and
-# probe at runtime to enable if the device does not support native timeline
-# semaphore.
-option(IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORE
-       "Emulates timeline semaphore with binary semaphores and fences" OFF)
-
-# Unconditionally turn on emulated timleine semaphore for Android.
-if(CMAKE_CROSSCOMPILING AND "${CMAKE_SYSTEM_NAME}" MATCHES "Android")
-  set(IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORE ON CACHE BOOL "" FORCE)
-endif()
-# Unless we are not compiling Vulkan HAL backend in.
-if(NOT IREE_HAL_DRIVER_VULKAN)
-  set(IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORE OFF CACHE BOOL "" FORCE)
-endif()
-
-if(IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORE)
-  set(IREE_EMULATE_TIMELINE_SEMAPHORE 1)
-else()
-  set(IREE_EMULATE_TIMELINE_SEMAPHORE 0)
-endif()
-
 set(VMA_SRC_ROOT
   "${IREE_ROOT_DIR}/third_party/vulkan_memory_allocator/src/"
 )
@@ -522,7 +501,6 @@
   SRCS
     "vulkan_device.cc"
   COPTS
-    "-DIREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES=${IREE_EMULATE_TIMELINE_SEMAPHORE}"
     "-DVK_NO_PROTOTYPES"
   DEPS
     ::descriptor_pool_cache
@@ -592,7 +570,6 @@
   SRCS
     "vulkan_driver_module.cc"
   COPTS
-    "-DIREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES=${IREE_EMULATE_TIMELINE_SEMAPHORE}"
     "-DVK_NO_PROTOTYPES"
   DEPS
     absl::flags
diff --git a/iree/hal/vulkan/timepoint_util.h b/iree/hal/vulkan/timepoint_util.h
index e2cb7df..7cd6370 100644
--- a/iree/hal/vulkan/timepoint_util.h
+++ b/iree/hal/vulkan/timepoint_util.h
@@ -117,7 +117,7 @@
 // all the semaphores in the same submission to a `VkQueue`.
 class TimePointFencePool final : public RefObject<TimePointFencePool> {
  public:
-  static constexpr int kMaxInFlightFenceCount = 32;
+  static constexpr int kMaxInFlightFenceCount = 128;
 
   // Creates a new pool and pre-allocates `kMaxInFlightFenceCount` fences.
   static StatusOr<ref_ptr<TimePointFencePool>> Create(
diff --git a/iree/hal/vulkan/vulkan_device.cc b/iree/hal/vulkan/vulkan_device.cc
index 2f2d16e..0747b1e 100644
--- a/iree/hal/vulkan/vulkan_device.cc
+++ b/iree/hal/vulkan/vulkan_device.cc
@@ -178,17 +178,18 @@
     syms->vkGetDeviceQueue(*logical_device,
                            compute_queue_set.queue_family_index, i, &queue);
     std::string queue_name = absl::StrCat(device_info.name(), ":d", i);
-#if IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
-    command_queues.push_back(absl::make_unique<SerializingCommandQueue>(
-        std::move(queue_name),
-        CommandCategory::kDispatch | CommandCategory::kTransfer, logical_device,
-        fence_pool, queue));
-#else
-    command_queues.push_back(absl::make_unique<DirectCommandQueue>(
-        std::move(queue_name),
-        CommandCategory::kDispatch | CommandCategory::kTransfer, logical_device,
-        queue));
-#endif  // IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
+
+    if (fence_pool != nullptr) {
+      command_queues.push_back(absl::make_unique<SerializingCommandQueue>(
+          std::move(queue_name),
+          CommandCategory::kDispatch | CommandCategory::kTransfer,
+          logical_device, fence_pool, queue));
+    } else {
+      command_queues.push_back(absl::make_unique<DirectCommandQueue>(
+          std::move(queue_name),
+          CommandCategory::kDispatch | CommandCategory::kTransfer,
+          logical_device, queue));
+    }
   }
 
   uint64_t transfer_queue_count = CountOnes64(transfer_queue_set.queue_indices);
@@ -199,15 +200,15 @@
     syms->vkGetDeviceQueue(*logical_device,
                            transfer_queue_set.queue_family_index, i, &queue);
     std::string queue_name = absl::StrCat(device_info.name(), ":t", i);
-#if IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
-    command_queues.push_back(absl::make_unique<SerializingCommandQueue>(
-        std::move(queue_name), CommandCategory::kTransfer, logical_device,
-        fence_pool, queue));
-#else
-    command_queues.push_back(absl::make_unique<DirectCommandQueue>(
-        std::move(queue_name), CommandCategory::kTransfer, logical_device,
-        queue));
-#endif  // IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
+    if (fence_pool != nullptr) {
+      command_queues.push_back(absl::make_unique<SerializingCommandQueue>(
+          std::move(queue_name), CommandCategory::kTransfer, logical_device,
+          fence_pool, queue));
+    } else {
+      command_queues.push_back(absl::make_unique<DirectCommandQueue>(
+          std::move(queue_name), CommandCategory::kTransfer, logical_device,
+          queue));
+    }
   }
 
   return command_queues;
@@ -371,15 +372,16 @@
     transfer_queue_set.queue_indices |= 1 << (i + base_queue_index);
   }
 
-#if IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
-  ASSIGN_OR_RETURN(auto semaphore_pool,
-                   TimePointSemaphorePool::Create(add_ref(logical_device)));
-  ASSIGN_OR_RETURN(auto fence_pool,
-                   TimePointFencePool::Create(add_ref(logical_device)));
-#else
+  // Emulate timeline semaphores if associated functions are not defined.
+  // TODO(scotttodd): define / compiler flag to force emulation
   ref_ptr<TimePointSemaphorePool> semaphore_pool = nullptr;
   ref_ptr<TimePointFencePool> fence_pool = nullptr;
-#endif  // IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
+  if (syms->vkGetSemaphoreCounterValue == nullptr) {
+    ASSIGN_OR_RETURN(semaphore_pool,
+                     TimePointSemaphorePool::Create(add_ref(logical_device)));
+    ASSIGN_OR_RETURN(fence_pool,
+                     TimePointFencePool::Create(add_ref(logical_device)));
+  }
 
   auto command_queues =
       CreateCommandQueues(device_info, logical_device, compute_queue_set,
@@ -450,15 +452,16 @@
                          device_handle, transfer_queue_set.queue_family_index));
   }
 
-#if IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
-  ASSIGN_OR_RETURN(auto semaphore_pool,
-                   TimePointSemaphorePool::Create(add_ref(device_handle)));
-  ASSIGN_OR_RETURN(auto fence_pool,
-                   TimePointFencePool::Create(add_ref(device_handle)));
-#else
+  // Emulate timeline semaphores if associated functions are not defined.
+  // TODO(scotttodd): define / compiler flag to force emulation
   ref_ptr<TimePointSemaphorePool> semaphore_pool = nullptr;
   ref_ptr<TimePointFencePool> fence_pool = nullptr;
-#endif  // IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
+  if (syms->vkGetSemaphoreCounterValue == nullptr) {
+    ASSIGN_OR_RETURN(semaphore_pool,
+                     TimePointSemaphorePool::Create(add_ref(device_handle)));
+    ASSIGN_OR_RETURN(fence_pool,
+                     TimePointFencePool::Create(add_ref(device_handle)));
+  }
 
   auto command_queues =
       CreateCommandQueues(device_info, device_handle, compute_queue_set,
@@ -695,36 +698,37 @@
 StatusOr<ref_ptr<Semaphore>> VulkanDevice::CreateSemaphore(
     uint64_t initial_value) {
   IREE_TRACE_SCOPE0("VulkanDevice::CreateSemaphore");
-#if IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
-  return EmulatedTimelineSemaphore::Create(
-      add_ref(logical_device_),
-      // Triggers necessary processing on all queues due to new values gotten
-      // signaled for the given timeline |semaphore|.
-      // Different clang-format versions disagree about the asterisk placement.
-      // clang-format off
-      [this](Semaphore* /*semaphore*/) -> Status {
-        // clang-format on
-        IREE_TRACE_SCOPE0("<lambda>::OnSemaphoreSignal");
-        for (const auto& queue : command_queues_) {
-          RETURN_IF_ERROR(static_cast<SerializingCommandQueue*>(queue.get())
-                              ->AdvanceQueueSubmission());
-        }
-        return OkStatus();
-      },
-      // Triggers necessary processing on all queues due to failures for the
-      // given timeline |semaphore|.
-      [this](Semaphore* /*semaphore*/) {
-        IREE_TRACE_SCOPE0("<lambda>::OnSemaphoreFailure");
-        for (const auto& queue : command_queues_) {
-          static_cast<SerializingCommandQueue*>(queue.get())
-              ->AbortQueueSubmission();
-        }
-      },
-      add_ref(semaphore_pool_), initial_value);
-#else
+
+  if (emulating_timeline_semaphores()) {
+    return EmulatedTimelineSemaphore::Create(
+        add_ref(logical_device_),
+        // Triggers necessary processing on all queues due to new values gotten
+        // signaled for the given timeline |semaphore|.
+        // Different clang-format versions disagree about asterisk placement.
+        // clang-format off
+        [this](Semaphore* /*semaphore*/) -> Status {
+          // clang-format on
+          IREE_TRACE_SCOPE0("<lambda>::OnSemaphoreSignal");
+          for (const auto& queue : command_queues_) {
+            RETURN_IF_ERROR(static_cast<SerializingCommandQueue*>(queue.get())
+                                ->AdvanceQueueSubmission());
+          }
+          return OkStatus();
+        },
+        // Triggers necessary processing on all queues due to failures for the
+        // given timeline |semaphore|.
+        [this](Semaphore* /*semaphore*/) {
+          IREE_TRACE_SCOPE0("<lambda>::OnSemaphoreFailure");
+          for (const auto& queue : command_queues_) {
+            static_cast<SerializingCommandQueue*>(queue.get())
+                ->AbortQueueSubmission();
+          }
+        },
+        add_ref(semaphore_pool_), initial_value);
+  }
+
   return NativeTimelineSemaphore::Create(add_ref(logical_device_),
                                          initial_value);
-#endif  // IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
 }
 
 Status VulkanDevice::WaitAllSemaphores(
@@ -745,23 +749,22 @@
                                     VkSemaphoreWaitFlags wait_flags) {
   IREE_TRACE_SCOPE0("VulkanDevice::WaitSemaphores");
 
-#if IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
+  if (emulating_timeline_semaphores()) {
+    // TODO(antiagainst): We actually should get the fences associated with the
+    // emulated timeline semaphores so that we can wait them in a bunch. This
+    // implementation is problematic if we wait to wait any and we have the
+    // first semaphore taking extra long time but the following ones signal
+    // quickly.
+    for (int i = 0; i < semaphores.size(); ++i) {
+      auto* semaphore =
+          static_cast<EmulatedTimelineSemaphore*>(semaphores[i].semaphore);
+      RETURN_IF_ERROR(semaphore->Wait(semaphores[i].value, deadline));
+      if (wait_flags & VK_SEMAPHORE_WAIT_ANY_BIT) return OkStatus();
+    }
 
-  // TODO(antiagainst): We actually should get the fences associated with the
-  // emulated timeline semaphores so that we can wait them in a bunch. This
-  // implementation is problematic if we wait to wait any and we have the first
-  // semaphore taking extra long time but the following ones signal quickly.
-  for (int i = 0; i < semaphores.size(); ++i) {
-    auto* semaphore =
-        static_cast<EmulatedTimelineSemaphore*>(semaphores[i].semaphore);
-    RETURN_IF_ERROR(semaphore->Wait(semaphores[i].value, deadline));
-    if (wait_flags & VK_SEMAPHORE_WAIT_ANY_BIT) return OkStatus();
+    return OkStatus();
   }
 
-  return OkStatus();
-
-#else
-
   absl::InlinedVector<VkSemaphore, 4> semaphore_handles(semaphores.size());
   absl::InlinedVector<uint64_t, 4> semaphore_values(semaphores.size());
   for (int i = 0; i < semaphores.size(); ++i) {
@@ -804,8 +807,6 @@
   // semaphores we waited on (including those already expired above).
 
   return OkStatus();
-
-#endif  // IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES
 }
 
 Status VulkanDevice::WaitIdle(absl::Time deadline) {
diff --git a/iree/hal/vulkan/vulkan_device.h b/iree/hal/vulkan/vulkan_device.h
index ce7c9d7..4032bbf 100644
--- a/iree/hal/vulkan/vulkan_device.h
+++ b/iree/hal/vulkan/vulkan_device.h
@@ -127,6 +127,10 @@
   Status WaitSemaphores(absl::Span<const SemaphoreValue> semaphores,
                         absl::Time deadline, VkSemaphoreWaitFlags wait_flags);
 
+  bool emulating_timeline_semaphores() const {
+    return semaphore_pool_ != nullptr;
+  }
+
   ref_ptr<Driver> driver_;
   VkPhysicalDevice physical_device_;
   ref_ptr<VkDeviceHandle> logical_device_;
diff --git a/iree/hal/vulkan/vulkan_driver_module.cc b/iree/hal/vulkan/vulkan_driver_module.cc
index f034127..0426868 100644
--- a/iree/hal/vulkan/vulkan_driver_module.cc
+++ b/iree/hal/vulkan/vulkan_driver_module.cc
@@ -67,11 +67,13 @@
   // promoted to core, so we list it as optional even though we require it.
   options.instance_extensibility.optional_extensions.push_back(
       VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
-#if IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORES == 0
-  // Timeline semaphore support is required.
-  options.device_extensibility.required_extensions.push_back(
+
+  // Timeline semaphore support is optional and will be emulated if necessary.
+  options.device_extensibility.optional_extensions.push_back(
       VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME);
-#endif
+  // Polyfill layer - enable if present (instead of our custom emulation).
+  options.instance_extensibility.optional_layers.push_back(
+      "VK_LAYER_KHRONOS_timeline_semaphore");
 
   if (absl::GetFlag(FLAGS_vulkan_validation_layers)) {
     options.instance_extensibility.optional_layers.push_back(
@@ -92,10 +94,6 @@
         VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
   }
 
-  // Polyfill layer - enable if present.
-  options.instance_extensibility.optional_layers.push_back(
-      "VK_LAYER_KHRONOS_timeline_semaphore");
-
   // Create the driver and VkInstance.
   ASSIGN_OR_RETURN(auto driver, VulkanDriver::Create(options, std::move(syms)));
 
diff --git a/scripts/update_e2e_coverage.py b/scripts/update_e2e_coverage.py
index 32a3177..ea691e4 100755
--- a/scripts/update_e2e_coverage.py
+++ b/scripts/update_e2e_coverage.py
@@ -98,12 +98,12 @@
   # Check if the suite exists (which may not be true for failing suites)
   target_dir = test_suite.split(':')[0]
   query = ['bazel', 'query', f'{target_dir}/...']
-  targets = subprocess.check_output(query, stderr=subprocess.DEVNULL)
+  targets = subprocess.check_output(query)
   if test_suite_path not in targets.decode('ascii'):
     return []
 
   query = ['bazel', 'query', f'tests({test_suite_path})']
-  tests = subprocess.check_output(query, stderr=subprocess.DEVNULL)
+  tests = subprocess.check_output(query)
   tests = tests.decode('ascii').split('\n')
   tests = list(filter(lambda s: s.startswith(f'{test_suite_path}_'), tests))
   tests = [test.replace(f'{test_suite_path}_', '') for test in tests]
diff --git a/third_party/llvm-project b/third_party/llvm-project
index f0bab78..1becd29 160000
--- a/third_party/llvm-project
+++ b/third_party/llvm-project
@@ -1 +1 @@
-Subproject commit f0bab7875e78e01c149d12302dcc4b6d4c43e25c
+Subproject commit 1becd298b82ed2f1a8ba5e61c5ad2ce7fe32d812
diff --git a/third_party/vulkan_extensionlayer b/third_party/vulkan_extensionlayer
deleted file mode 160000
index 8a457f8..0000000
--- a/third_party/vulkan_extensionlayer
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 8a457f8552d8d47ce3a96ed80a714ff6396f8ad8