Integrate llvm/llvm-project@406b3f2c (#12199)

LLVM_COMMIT=”406b3f2cbbee764578184e19de42d3a0602883aa”
MHLO_COMMIT=”63ac2f8f3989266b65fc3150bd25648f75e34a62”
TF_COMMIT=”d1c09628895840a713e92e8557b5fd90afa94c18”

Cherry picked a few upstream fixes:
* llvm/llvm-project@5205c71
* llvm/llvm-project@3cf7f22
* llvm/llvm-project@1842b58

---------

Co-authored-by: Kojo Acquah <kooljblack@google.com>
Co-authored-by: Alex Zinenko <zinenko@google.com>
Co-authored-by: Thomas Raoux <thomasraoux@google.com>
diff --git a/compiler/src/iree/compiler/API2/Internal/BUILD b/compiler/src/iree/compiler/API2/Internal/BUILD
index 32eddec..e57188c 100644
--- a/compiler/src/iree/compiler/API2/Internal/BUILD
+++ b/compiler/src/iree/compiler/API2/Internal/BUILD
@@ -92,6 +92,7 @@
         "@llvm-project//lld:MachO",
         "@llvm-project//lld:Wasm",
         "@llvm-project//llvm:Support",
+        "@llvm-project//llvm:TargetParser",
     ],
 )
 
diff --git a/compiler/src/iree/compiler/API2/Internal/CMakeLists.txt b/compiler/src/iree/compiler/API2/Internal/CMakeLists.txt
index 8c1a346..99c2c88 100644
--- a/compiler/src/iree/compiler/API2/Internal/CMakeLists.txt
+++ b/compiler/src/iree/compiler/API2/Internal/CMakeLists.txt
@@ -83,6 +83,7 @@
     "LLDToolEntryPoint.cpp"
   DEPS
     LLVMSupport
+    LLVMTargetParser
     iree::compiler::API2::Headers
     lldCOFF
     lldCommon
diff --git a/compiler/src/iree/compiler/API2/Internal/LLDToolEntryPoint.cpp b/compiler/src/iree/compiler/API2/Internal/LLDToolEntryPoint.cpp
index 4e5b645..f5dd5a4 100644
--- a/compiler/src/iree/compiler/API2/Internal/LLDToolEntryPoint.cpp
+++ b/compiler/src/iree/compiler/API2/Internal/LLDToolEntryPoint.cpp
@@ -19,7 +19,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/CrashRecoveryContext.h"
@@ -28,6 +27,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PluginLoader.h"
 #include "llvm/Support/Process.h"
+#include "llvm/TargetParser/Triple.h"
 
 using namespace lld;
 using namespace llvm;
diff --git a/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.cpp b/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.cpp
index 9416cb1..90a8a95 100644
--- a/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.cpp
+++ b/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.cpp
@@ -25,10 +25,13 @@
 #include "mlir/Dialect/Vector/Transforms/BufferizableOpInterfaceImpl.h"
 #include "mlir/Support/LLVM.h"
 
+using mlir::bufferization::AliasingOpOperand;
+using mlir::bufferization::AliasingOpOperandList;
+using mlir::bufferization::AliasingOpResult;
 using mlir::bufferization::AnalysisState;
 using mlir::bufferization::BufferizableOpInterface;
-using mlir::bufferization::BufferizationAliasInfo;
 using mlir::bufferization::BufferizationOptions;
+using mlir::bufferization::BufferRelation;
 using mlir::bufferization::eliminateEmptyTensors;
 using mlir::bufferization::OneShotAnalysisState;
 using mlir::bufferization::OneShotBufferizationOptions;
@@ -264,11 +267,12 @@
   AnalysisState analysisState(options);
   SmallVector<Value> newOutputBuffers;
   for (OpResult opResult : op->getOpResults()) {
-    SmallVector<OpOperand *> aliasingOpOperands =
+    AliasingOpOperandList aliasingOpOperands =
         analysisState.getAliasingOpOperands(opResult);
-    assert(aliasingOpOperands.size() == 1 && "expected 1 OpOperand");
-    FailureOr<Value> resultBuffer =
-        getBuffer(rewriter, aliasingOpOperands.front()->get(), options);
+    assert(aliasingOpOperands.getNumAliases() == 1 && "expected 1 OpOperand");
+    FailureOr<Value> resultBuffer = getBuffer(
+        rewriter, aliasingOpOperands.getAliases().front().opOperand->get(),
+        options);
     if (failed(resultBuffer)) return failure();
     newOutputBuffers.push_back(*resultBuffer);
   }
@@ -321,7 +325,9 @@
                                const AnalysisState &state) const {
     // Operand is written to if it has an aliasing OpResult.
     auto bufferizableOp = cast<BufferizableOpInterface>(op);
-    return !bufferizableOp.getAliasingOpResults(opOperand, state).empty();
+    return !bufferizableOp.getAliasingOpResults(opOperand, state)
+                .getAliases()
+                .empty();
   }
 
   bufferization::AliasingOpOperandList getAliasingOpOperands(
@@ -329,7 +335,10 @@
     auto linalgExtOp = cast<IREE::LinalgExt::LinalgExtOp>(op);
 
     // The i-th OpResult may alias with the i-th "out" tensor.
-    return {linalgExtOp.getOutputOperand(opResult.getResultNumber())};
+    return {AliasingOpOperand(
+        linalgExtOp.getOutputOperand(opResult.getResultNumber()) /*result*/,
+        BufferRelation::Equivalent,
+        /*isDefinite=*/false)};
   }
 
   bufferization::AliasingOpResultList getAliasingOpResults(
@@ -337,7 +346,11 @@
     auto dspOp = cast<DestinationStyleOpInterface>(op);
 
     // The i-th "out" tensor may alias with the i-th OpResult.
-    if (dspOp.isDpsInit(&opOperand)) return {dspOp.getTiedOpResult(&opOperand)};
+    if (dspOp.isDpsInit(&opOperand)) {
+      return {AliasingOpResult(dspOp.getTiedOpResult(&opOperand) /*result*/,
+                               BufferRelation::Equivalent,
+                               /*isDefinite=*/false)};
+    }
     return {};
   }
 
@@ -366,11 +379,12 @@
 
   Value dest;
   AnalysisState analysisState(options);
-  SmallVector<OpOperand *> aliasingOpOperands =
+  AliasingOpOperandList aliasingOpOperands =
       analysisState.getAliasingOpOperands(op->getOpResult(0));
-  assert(aliasingOpOperands.size() == 1 && "expected 1 OpOperand");
-  FailureOr<Value> resultBuffer =
-      getBuffer(rewriter, aliasingOpOperands.front()->get(), options);
+  assert(aliasingOpOperands.getNumAliases() == 1 && "expected 1 OpOperand");
+  FailureOr<Value> resultBuffer = getBuffer(
+      rewriter, aliasingOpOperands.getAliases().front().opOperand->get(),
+      options);
   if (failed(resultBuffer)) return failure();
   dest = *resultBuffer;
   return std::make_pair(source, dest);
@@ -459,7 +473,10 @@
     auto dspOp = cast<DestinationStyleOpInterface>(op);
 
     // The i-th "out" tensor may alias with the i-th OpResult.
-    if (dspOp.isDpsInit(&opOperand)) return {dspOp.getTiedOpResult(&opOperand)};
+    if (dspOp.isDpsInit(&opOperand))
+      return {AliasingOpResult(dspOp.getTiedOpResult(&opOperand),
+                               BufferRelation::Equivalent,
+                               /*isDefinite=*/false)};
     return {};
   }
 
@@ -487,7 +504,7 @@
 /// Returns true if the value of a `storeOp` bufferizes to an equivalent
 /// DispatchTensorLoadOp result that bufferizes inplace.
 static bool isValueEquivalentToAnInplaceTensorLoadOp(
-    const BufferizationAliasInfo &aliasInfo,
+    const OneShotAnalysisState &aliasInfo,
     IREE::Flow::DispatchTensorStoreOp storeOp) {
   bool foundOp = false;
   aliasInfo.applyOnEquivalenceClass(storeOp.getValue(), [&](Value value) {
@@ -513,7 +530,7 @@
 ///   DispatchTensorStoreOp to the tensor::EmptyOp must have bufferized
 ///   in-place.
 LogicalResult storeTensorOpAnchoredEmptyTensorEliminationStep(
-    RewriterBase &rewriter, Operation *op, AnalysisState &state) {
+    RewriterBase &rewriter, Operation *op, OneShotAnalysisState &state) {
   return eliminateEmptyTensors(
       rewriter, op, state,
       /*anchorMatchFunc=*/
diff --git a/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.h b/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.h
index a3182ff..c34bcd7 100644
--- a/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.h
+++ b/compiler/src/iree/compiler/Codegen/Interfaces/BufferizationInterfaces.h
@@ -19,7 +19,8 @@
 
 // Eliminate tensor.empty ops that are anchored on flow store ops.
 LogicalResult storeTensorOpAnchoredEmptyTensorEliminationStep(
-    RewriterBase &rewriter, Operation *op, bufferization::AnalysisState &state);
+    RewriterBase &rewriter, Operation *op,
+    bufferization::OneShotAnalysisState &state);
 
 }  // namespace iree_compiler
 }  // namespace mlir
diff --git a/compiler/src/iree/compiler/Codegen/LLVMCPU/BUILD b/compiler/src/iree/compiler/Codegen/LLVMCPU/BUILD
index a29a469..744c688 100644
--- a/compiler/src/iree/compiler/Codegen/LLVMCPU/BUILD
+++ b/compiler/src/iree/compiler/Codegen/LLVMCPU/BUILD
@@ -63,6 +63,7 @@
         "//runtime/src/iree/builtins/ukernel:exported_bits",
         "@llvm-project//llvm:BinaryFormat",
         "@llvm-project//llvm:Support",
+        "@llvm-project//llvm:TargetParser",
         "@llvm-project//mlir:AffineDialect",
         "@llvm-project//mlir:AffineToStandard",
         "@llvm-project//mlir:Analysis",
diff --git a/compiler/src/iree/compiler/Codegen/LLVMCPU/CMakeLists.txt b/compiler/src/iree/compiler/Codegen/LLVMCPU/CMakeLists.txt
index 85224a4..948f734 100644
--- a/compiler/src/iree/compiler/Codegen/LLVMCPU/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Codegen/LLVMCPU/CMakeLists.txt
@@ -43,6 +43,7 @@
     IREELinalgTransformDialectPasses
     LLVMBinaryFormat
     LLVMSupport
+    LLVMTargetParser
     MLIRAffineDialect
     MLIRAffineToStandard
     MLIRAnalysis
diff --git a/compiler/src/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp b/compiler/src/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp
index 0cbac1e..1c7aae3 100644
--- a/compiler/src/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp
+++ b/compiler/src/iree/compiler/Codegen/LLVMCPU/ConvertToLLVM.cpp
@@ -12,9 +12,9 @@
 #include "iree/compiler/Dialect/HAL/IR/HALOps.h"
 #include "iree/compiler/Dialect/Util/IR/UtilDialect.h"
 #include "iree/compiler/Dialect/Util/IR/UtilOps.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/TargetParser/Triple.h"
 #include "mlir/Analysis/DataLayoutAnalysis.h"
 #include "mlir/Conversion/AffineToStandard/AffineToStandard.h"
 #include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h"
diff --git a/compiler/src/iree/compiler/Codegen/LLVMCPU/VectorContractCustomKernels.cpp b/compiler/src/iree/compiler/Codegen/LLVMCPU/VectorContractCustomKernels.cpp
index 0e9d62d..7e186f7 100644
--- a/compiler/src/iree/compiler/Codegen/LLVMCPU/VectorContractCustomKernels.cpp
+++ b/compiler/src/iree/compiler/Codegen/LLVMCPU/VectorContractCustomKernels.cpp
@@ -11,8 +11,8 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/TargetParser/Triple.h"
 #include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h"
 #include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
 #include "mlir/Dialect/Arith/IR/Arith.h"
diff --git a/compiler/src/iree/compiler/Codegen/LLVMGPU/test/reduction_pipeline.mlir b/compiler/src/iree/compiler/Codegen/LLVMGPU/test/reduction_pipeline.mlir
index 56bb89e..7a31604 100644
--- a/compiler/src/iree/compiler/Codegen/LLVMGPU/test/reduction_pipeline.mlir
+++ b/compiler/src/iree/compiler/Codegen/LLVMGPU/test/reduction_pipeline.mlir
@@ -317,7 +317,6 @@
 //         CHECK:    arith.addf
 //         CHECK:    arith.addf
 //         CHECK:    vector.broadcast
-//         CHECK:    vector.broadcast
 //         CHECK:    arith.divf
 //         CHECK:    scf.for
 //         CHECK:      vector.transfer_read
diff --git a/compiler/src/iree/compiler/Codegen/Utils/BUILD b/compiler/src/iree/compiler/Codegen/Utils/BUILD
index 5dd02b9..b0a3934 100644
--- a/compiler/src/iree/compiler/Codegen/Utils/BUILD
+++ b/compiler/src/iree/compiler/Codegen/Utils/BUILD
@@ -38,6 +38,7 @@
         "//llvm-external-projects/iree-dialects:IREELinalgExtDialect",
         "//llvm-external-projects/iree-dialects:IREELinalgExtPasses",
         "@llvm-project//llvm:Support",
+        "@llvm-project//llvm:TargetParser",
         "@llvm-project//mlir:AffineDialect",
         "@llvm-project//mlir:ArithDialect",
         "@llvm-project//mlir:ArithUtils",
diff --git a/compiler/src/iree/compiler/Codegen/Utils/CMakeLists.txt b/compiler/src/iree/compiler/Codegen/Utils/CMakeLists.txt
index e11c0ef..97027f5 100644
--- a/compiler/src/iree/compiler/Codegen/Utils/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Codegen/Utils/CMakeLists.txt
@@ -29,6 +29,7 @@
     IREELinalgExtDialect
     IREELinalgExtPasses
     LLVMSupport
+    LLVMTargetParser
     MLIRAffineDialect
     MLIRArithDialect
     MLIRArithUtils
diff --git a/compiler/src/iree/compiler/Codegen/Utils/Utils.h b/compiler/src/iree/compiler/Codegen/Utils/Utils.h
index 0e45fda..ca8f43f 100644
--- a/compiler/src/iree/compiler/Codegen/Utils/Utils.h
+++ b/compiler/src/iree/compiler/Codegen/Utils/Utils.h
@@ -10,7 +10,7 @@
 #include "iree/compiler/Codegen/Interfaces/PartitionableLoopsInterface.h"
 #include "iree/compiler/Dialect/HAL/IR/HALOps.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/Triple.h"
+#include "llvm/TargetParser/Triple.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/Utils/Utils.h"
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/BUILD b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/BUILD
index a6c0057..ebf3702 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/BUILD
+++ b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/BUILD
@@ -57,6 +57,7 @@
         "@llvm-project//llvm:RISCVAsmParser",
         "@llvm-project//llvm:RISCVCodeGen",
         "@llvm-project//llvm:Support",
+        "@llvm-project//llvm:TargetParser",
         "@llvm-project//llvm:WebAssemblyAsmParser",
         "@llvm-project//llvm:WebAssemblyCodeGen",
         "@llvm-project//llvm:X86AsmParser",
@@ -117,8 +118,9 @@
     hdrs = ["LinkerTool.h"],
     deps = platform_trampoline_deps("LinkerTools", "compiler/src/iree/compiler/Dialect/HAL/Target/LLVM") + [
         "//compiler/src/iree/compiler/Utils",
-        "@llvm-project//llvm:Support",
         "@llvm-project//llvm:Core",
+        "@llvm-project//llvm:Support",
+        "@llvm-project//llvm:TargetParser",
         "@llvm-project//mlir:Support",
         ":LLVMTargetOptions",
     ],
@@ -131,6 +133,7 @@
         ":LLVMTargetOptions",
         "@llvm-project//llvm:Core",
         "@llvm-project//llvm:Support",
+        "@llvm-project//llvm:TargetParser",
         "@llvm-project//mlir:Support",
     ],
 )
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt
index fe7facd..9d4b5d6 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/CMakeLists.txt
@@ -37,6 +37,7 @@
     LLVMCore
     LLVMLinker
     LLVMSupport
+    LLVMTargetParser
     MLIRArmNeonDialect
     MLIRLLVMDialect
     MLIRLLVMToLLVMIRTranslation
@@ -103,6 +104,7 @@
     ::LLVMTargetOptions
     LLVMCore
     LLVMSupport
+    LLVMTargetParser
     MLIRSupport
     iree::compiler::Dialect::HAL::Target::LLVM::internal::LinkerTools_internal
     iree::compiler::Utils
@@ -118,6 +120,7 @@
     ::LLVMTargetOptions
     LLVMCore
     LLVMSupport
+    LLVMTargetParser
     MLIRSupport
   PUBLIC
 )
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.cpp b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.cpp
index ef46e6e..f2d8a5e 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.cpp
+++ b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.cpp
@@ -9,12 +9,12 @@
 #include <mutex>
 
 #include "llvm/ADT/APFloat.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Target/TargetOptions.h"
+#include "llvm/TargetParser/Triple.h"
 #include "llvm/TargetParser/X86TargetParser.h"
 
 namespace mlir {
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LibraryBuilder.h b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LibraryBuilder.h
index e1baa0a..dff4e32 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LibraryBuilder.h
+++ b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LibraryBuilder.h
@@ -11,8 +11,8 @@
 #include <string>
 
 #include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/IR/Module.h"
+#include "llvm/TargetParser/Triple.h"
 #include "mlir/Support/LogicalResult.h"
 
 namespace mlir {
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.h b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.h
index 0036762..246c8f7 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.h
+++ b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.h
@@ -11,11 +11,11 @@
 #include <string>
 
 #include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMTargetOptions.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/TargetParser/Triple.h"
 #include "mlir/Support/LogicalResult.h"
 
 namespace mlir {
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/AndroidLinkerTool.cpp b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/AndroidLinkerTool.cpp
index f1b7756..98e4b0f 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/AndroidLinkerTool.cpp
+++ b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/AndroidLinkerTool.cpp
@@ -5,11 +5,11 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 #include "iree/compiler/Dialect/HAL/Target/LLVM/LinkerTool.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Host.h"
+#include "llvm/TargetParser/Triple.h"
 
 #define DEBUG_TYPE "llvm-linker"
 
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/BUILD b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/BUILD
index f6232f4..454ccdc 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/BUILD
+++ b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/BUILD
@@ -26,6 +26,7 @@
         "//compiler/src/iree/compiler/Dialect/HAL/Target/LLVM:LinkerTool_hdrs",
         "@llvm-project//llvm:Core",
         "@llvm-project//llvm:Support",
+        "@llvm-project//llvm:TargetParser",
         "@llvm-project//mlir:Support",
     ],
 )
diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt
index 2c28fe7..80e126d 100644
--- a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVM/internal/CMakeLists.txt
@@ -23,6 +23,7 @@
   DEPS
     LLVMCore
     LLVMSupport
+    LLVMTargetParser
     MLIRSupport
     iree::compiler::Dialect::HAL::Target::LLVM::LinkerTool_hdrs
   PUBLIC
diff --git a/integrations/tensorflow/WORKSPACE b/integrations/tensorflow/WORKSPACE
index 9f8c537..e94d707 100644
--- a/integrations/tensorflow/WORKSPACE
+++ b/integrations/tensorflow/WORKSPACE
@@ -7,7 +7,7 @@
 
 load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
 
-TENSORFLOW_COMMIT = "89a60b5149c6e430521d331535a49ac47358e014"
+TENSORFLOW_COMMIT = "d1c09628895840a713e92e8557b5fd90afa94c18"
 
 git_repository(
     name = "org_tensorflow",
diff --git a/llvm-external-projects/iree-dialects/lib/Dialect/LinalgTransform/IR/StructuredTransformOpsExt.cpp b/llvm-external-projects/iree-dialects/lib/Dialect/LinalgTransform/IR/StructuredTransformOpsExt.cpp
index c6d35b6..5d75f46 100644
--- a/llvm-external-projects/iree-dialects/lib/Dialect/LinalgTransform/IR/StructuredTransformOpsExt.cpp
+++ b/llvm-external-projects/iree-dialects/lib/Dialect/LinalgTransform/IR/StructuredTransformOpsExt.cpp
@@ -599,7 +599,8 @@
   for (Value operand : transform->getOperands()) {
     if (transform::isHandleConsumed(operand, transform))
       continue;
-
+    if (!operand.getType().isa<transform::TransformHandleTypeInterface>())
+      continue;
     for (Operation *payload : state.getPayloadOps(operand)) {
       if (!payload || seen.contains(payload))
         continue;
@@ -613,7 +614,8 @@
         return !handlesUsedAfterTransform[handle];
       });
       if (allHandlesUnused) {
-        listener->removeMappings(payload);
+        // Store for mapping removal, but not remove immediately because it
+        // could invalidate other handles.
         seen.insert(payload);
       }
     }
@@ -623,13 +625,20 @@
   for (Value result : transform->getResults()) {
     if (!result.getUses().empty())
       continue;
+    if (!result.getType().isa<transform::TransformHandleTypeInterface>())
+      continue;
     for (Operation *payload : state.getPayloadOps(result)) {
       if (!payload || seen.contains(payload))
         continue;
-      listener->removeMappings(payload);
+      // Store for mapping removal, but not remove immediately because it could
+      // invalidate other handles.
       seen.insert(payload);
     }
   }
+
+  // Remove everything in one bunch.
+  for (Operation *payload : seen)
+    listener->removeMappings(payload);
 }
 
 DiagnosedSilenceableFailure transform_ext::CanonicalizedSequenceOp::apply(
diff --git a/third_party/llvm-project b/third_party/llvm-project
index 27aeb58..947c8b4 160000
--- a/third_party/llvm-project
+++ b/third_party/llvm-project
@@ -1 +1 @@
-Subproject commit 27aeb58ce4d12e15b966dba86738eb65a96703f7
+Subproject commit 947c8b4b5869f18b1807863138271b3149ffc245
diff --git a/third_party/mlir-hlo b/third_party/mlir-hlo
index 8c44941..63ac2f8 160000
--- a/third_party/mlir-hlo
+++ b/third_party/mlir-hlo
@@ -1 +1 @@
-Subproject commit 8c4494120daca5dd2654bfddac1e64f2a741d65b
+Subproject commit 63ac2f8f3989266b65fc3150bd25648f75e34a62