Merge pull request #2839 from ScottTodd/google-to-main

* 1ed5aa41 Synchronize submodules
* 3239b6eb Integrate TF at tensorflow/tensorflow@8a4ffe2e1ae7
* 0c763339 Synchronize submodules
* 258e4543 Integrate LLVM at llvm/llvm-project@54cb552b9620
* df5e3e75 Synchronize submodules
* 5890d1f5 Integrate LLVM at llvm/llvm-project@38537307e502
* da781263 Synchronize submodules
* 3a8c06a5 Integrate LLVM at llvm/llvm-project@b6d9add71b1a
* 3431425c Synchronize submodules
* 47253ccf Integrate TF at tensorflow/tensorflow@595776085e1b
* 688360a5 Merge pull request #2821 from hanhanW:main-to-google
diff --git a/SUBMODULE_VERSIONS b/SUBMODULE_VERSIONS
index 65b8b06..e759097 100644
--- a/SUBMODULE_VERSIONS
+++ b/SUBMODULE_VERSIONS
@@ -4,7 +4,7 @@
 a5d9d0f7d368054fd1691aedf1db4116efcc233e third_party/flatbuffers
 4fb0ff7069bd88ee85902f4d0bb62794e5f6d021 third_party/flatcc
 f2fb48c3b3d79a75a88a99fba6576b25d42ec528 third_party/googletest
-9dbdaea9a0e6f58417b5bd8980e7ea6723fd1783 third_party/llvm-project
+54cb552b962097d0e3ef7306b69a3c82cc7fff37 third_party/llvm-project
 17b12a4481daa150e2d1ea3ada086b551b856707 third_party/marl
 80885f899e12d55a45561ef758eea47bb340dbf1 third_party/mlir-emitc
 d8c7ee00a687ac369e62e2032514a93a9b413502 third_party/pybind11
@@ -12,7 +12,7 @@
 a1390ed39ec77ecfb574bc6fcd5bfc5e3adbdea9 third_party/sdl2
 f8bf11a0253a32375c32cad92c841237b96696c0 third_party/spirv_headers
 57eb48aed36160c4876bc8310d9ca84d42ee9e2a third_party/swiftshader
-0a764ff2fe38274592d721690cc29c5612010967 third_party/tensorflow
+8a4ffe2e1ae722cff5306778df0cfca8b7f503fe third_party/tensorflow
 864d86e8b6d21449474db5e9313dbff90aa9c24f third_party/tracy
 9bd3f561bcee3f01d22912de10bb07ce4e23d378 third_party/vulkan_headers
 909f36b714c9239ee0b112a321220213a474ba53 third_party/vulkan_memory_allocator
diff --git a/build_tools/bazel/third_party_import/llvm-project/overlay/llvm/BUILD.bazel b/build_tools/bazel/third_party_import/llvm-project/overlay/llvm/BUILD.bazel
index befc20c..13bc7bf 100644
--- a/build_tools/bazel/third_party_import/llvm-project/overlay/llvm/BUILD.bazel
+++ b/build_tools/bazel/third_party_import/llvm-project/overlay/llvm/BUILD.bazel
@@ -1556,7 +1556,9 @@
         ":BPFInfo",
         ":CodeGen",
         ":Core",
+        ":IPO",
         ":MC",
+        ":Scalar",
         ":SelectionDAG",
         ":Support",
         ":Target",
diff --git a/integrations/tensorflow/compiler/dialect/tf_strings/ir/dialect.cpp b/integrations/tensorflow/compiler/dialect/tf_strings/ir/dialect.cpp
index 4b7fbb0..0f2a336 100644
--- a/integrations/tensorflow/compiler/dialect/tf_strings/ir/dialect.cpp
+++ b/integrations/tensorflow/compiler/dialect/tf_strings/ir/dialect.cpp
@@ -33,7 +33,7 @@
 }  // namespace
 
 TFStringsDialect::TFStringsDialect(MLIRContext* context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<TFStringsDialect>()) {
   addInterfaces<TfStringsToHALConversionInterface>();
   addTypes<StringType>();
 
diff --git a/integrations/tensorflow/compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.cc b/integrations/tensorflow/compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.cc
index 3aafcbe..7e7d379 100644
--- a/integrations/tensorflow/compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.cc
+++ b/integrations/tensorflow/compiler/dialect/tf_tensorlist/ir/tf_tensorlist_dialect.cc
@@ -27,7 +27,8 @@
 //===----------------------------------------------------------------------===//
 
 TfTensorListDialect::TfTensorListDialect(MLIRContext *context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context,
+              TypeID::get<TfTensorListDialect>()) {
   addInterfaces<iree_compiler::TfTensorListToHALConversionInterface>();
   addOperations<
 #define GET_OP_LIST
diff --git a/iree/compiler/Dialect/Flow/IR/FlowDialect.cpp b/iree/compiler/Dialect/Flow/IR/FlowDialect.cpp
index d7e5a5c..9cf0362 100644
--- a/iree/compiler/Dialect/Flow/IR/FlowDialect.cpp
+++ b/iree/compiler/Dialect/Flow/IR/FlowDialect.cpp
@@ -45,7 +45,7 @@
 }  // namespace
 
 FlowDialect::FlowDialect(MLIRContext *context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<FlowDialect>()) {
   addInterfaces<FlowFolderInterface>();
 
 #define GET_OP_LIST
diff --git a/iree/compiler/Dialect/HAL/IR/HALDialect.cpp b/iree/compiler/Dialect/HAL/IR/HALDialect.cpp
index d6cb420..b7e84f3 100644
--- a/iree/compiler/Dialect/HAL/IR/HALDialect.cpp
+++ b/iree/compiler/Dialect/HAL/IR/HALDialect.cpp
@@ -81,7 +81,7 @@
 }  // namespace
 
 HALDialect::HALDialect(MLIRContext *context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<HALDialect>()) {
   addInterfaces<HALInlinerInterface, HALToVMConversionInterface>();
 
   addAttributes<DescriptorSetLayoutBindingAttr, MatchAlwaysAttr, MatchAnyAttr,
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp
index 8cb47b5..5ae2ce1 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/LLVMAOTTarget.cpp
@@ -21,6 +21,7 @@
 #include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRPasses.h"
 #include "iree/compiler/Dialect/HAL/Target/TargetRegistry.h"
 #include "iree/schemas/dylib_executable_def_generated.h"
+#include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/TargetSelect.h"
@@ -46,17 +47,16 @@
 
   LogicalResult serializeExecutable(IREE::HAL::ExecutableTargetOp targetOp,
                                     OpBuilder& executableBuilder) override {
-    // LLVM is not thread safe and currently translation shares an LLVMContext.
-    // Since we serialize executables from multiple threads we have to take a
-    // global lock here.
-    static llvm::sys::SmartMutex<true> mutex;
-    llvm::sys::SmartScopedLock<true> lock(mutex);
+    // Perform the translation in a separate context to avoid any
+    // multi-threading issues.
+    llvm::LLVMContext context;
 
     iree::DyLibExecutableDefT dyLibExecutableDef;
 
     // At this moment we are leaving MLIR LLVM dialect land translating module
     // into target independent LLVMIR.
-    auto llvmModule = mlir::translateModuleToLLVMIR(targetOp.getInnerModule());
+    auto llvmModule =
+        mlir::translateModuleToLLVMIR(targetOp.getInnerModule(), context);
     if (!llvmModule) {
       return failure();
     }
diff --git a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.cpp b/iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.cpp
index 128abd4..2d62318 100644
--- a/iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.cpp
+++ b/iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRTarget.cpp
@@ -18,6 +18,7 @@
 #include "iree/compiler/Dialect/HAL/Target/LLVM/LLVMIRPasses.h"
 #include "iree/compiler/Dialect/HAL/Target/TargetRegistry.h"
 #include "iree/schemas/llvmir_executable_def_generated.h"
+#include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/TargetSelect.h"
@@ -43,15 +44,14 @@
 
   LogicalResult serializeExecutable(IREE::HAL::ExecutableTargetOp targetOp,
                                     OpBuilder& executableBuilder) override {
-    // LLVM is not thread safe and currently translation shares an LLVMContext.
-    // Since we serialize executables from multiple threads we have to take a
-    // global lock here.
-    static llvm::sys::SmartMutex<true> mutex;
-    llvm::sys::SmartScopedLock<true> lock(mutex);
+    // Perform the translation to LLVM in a separate context to avoid
+    // multi-threading issues.
+    llvm::LLVMContext context;
 
     // At this moment we are leaving MLIR LLVM dialect land translating module
     // into target independent LLVMIR.
-    auto llvmModule = mlir::translateModuleToLLVMIR(targetOp.getInnerModule());
+    auto llvmModule =
+        mlir::translateModuleToLLVMIR(targetOp.getInnerModule(), context);
     if (!llvmModule) {
       return targetOp.emitError("Failed to translate executable to LLVM IR");
     }
diff --git a/iree/compiler/Dialect/IREE/IR/IREEDialect.cpp b/iree/compiler/Dialect/IREE/IR/IREEDialect.cpp
index ddd994e..cf95bff 100644
--- a/iree/compiler/Dialect/IREE/IR/IREEDialect.cpp
+++ b/iree/compiler/Dialect/IREE/IR/IREEDialect.cpp
@@ -30,7 +30,7 @@
 static DialectRegistration<IREEDialect> base_dialect;
 
 IREEDialect::IREEDialect(MLIRContext* context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<IREEDialect>()) {
   addTypes<IREE::ByteBufferType, IREE::MutableByteBufferType, IREE::PtrType>();
 #define GET_OP_LIST
   addOperations<
diff --git a/iree/compiler/Dialect/Modules/Check/IR/CheckDialect.cpp b/iree/compiler/Dialect/Modules/Check/IR/CheckDialect.cpp
index c36589f..d92c80e 100644
--- a/iree/compiler/Dialect/Modules/Check/IR/CheckDialect.cpp
+++ b/iree/compiler/Dialect/Modules/Check/IR/CheckDialect.cpp
@@ -63,7 +63,7 @@
 }  // namespace
 
 CheckDialect::CheckDialect(MLIRContext *context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<CheckDialect>()) {
   addInterfaces<CheckToVmConversionInterface>();
   addInterfaces<CheckToHalConversionInterface>();
 #define GET_OP_LIST
diff --git a/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc b/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc
index 87e336b..c0cc9f1 100644
--- a/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc
+++ b/iree/compiler/Dialect/Modules/Strings/IR/Dialect.cc
@@ -55,7 +55,7 @@
 }  // namespace
 
 StringsDialect::StringsDialect(MLIRContext *context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<StringsDialect>()) {
   addInterfaces<StringsToVMConversionInterface>();
 
   addTypes<StringType, StringTensorType>();
diff --git a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp
index 07afccd..3aa42b2 100644
--- a/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp
+++ b/iree/compiler/Dialect/Modules/TensorList/IR/TensorListDialect.cpp
@@ -56,7 +56,8 @@
 }  // namespace
 
 TensorListDialect::TensorListDialect(MLIRContext *context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context,
+              TypeID::get<TensorListDialect>()) {
   addInterfaces<TensorListToVMConversionInterface>();
 
   addTypes<TensorListType>();
diff --git a/iree/compiler/Dialect/Sequence/IR/SequenceDialect.cpp b/iree/compiler/Dialect/Sequence/IR/SequenceDialect.cpp
index bef773d..20a640b 100644
--- a/iree/compiler/Dialect/Sequence/IR/SequenceDialect.cpp
+++ b/iree/compiler/Dialect/Sequence/IR/SequenceDialect.cpp
@@ -31,7 +31,7 @@
 static DialectRegistration<SequenceDialect> sequence_dialect;
 
 SequenceDialect::SequenceDialect(MLIRContext* context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<SequenceDialect>()) {
   addTypes<SequenceType>();
 
 #define GET_OP_LIST
diff --git a/iree/compiler/Dialect/Shape/IR/ShapeDialect.cpp b/iree/compiler/Dialect/Shape/IR/ShapeDialect.cpp
index e1da082..451bc1d 100644
--- a/iree/compiler/Dialect/Shape/IR/ShapeDialect.cpp
+++ b/iree/compiler/Dialect/Shape/IR/ShapeDialect.cpp
@@ -44,7 +44,7 @@
 };
 
 ShapeDialect::ShapeDialect(MLIRContext* context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<ShapeDialect>()) {
   addTypes<Shape::RankedShapeType>();
   addInterfaces<ShapeInlinerInterface>();
 #define GET_OP_LIST
diff --git a/iree/compiler/Dialect/VM/IR/VMDialect.cpp b/iree/compiler/Dialect/VM/IR/VMDialect.cpp
index 6327790..8c2c1db 100644
--- a/iree/compiler/Dialect/VM/IR/VMDialect.cpp
+++ b/iree/compiler/Dialect/VM/IR/VMDialect.cpp
@@ -187,7 +187,7 @@
 }  // namespace
 
 VMDialect::VMDialect(MLIRContext *context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<VMDialect>()) {
   addTypes<IREE::VM::ListType, IREE::VM::OpaqueType, IREE::VM::RefType>();
   addInterfaces<VMInlinerInterface, VMOpAsmInterface, VMFolderInterface>();
 
diff --git a/iree/compiler/Dialect/VMLA/IR/VMLADialect.cpp b/iree/compiler/Dialect/VMLA/IR/VMLADialect.cpp
index 32f31e1..0ddb8df 100644
--- a/iree/compiler/Dialect/VMLA/IR/VMLADialect.cpp
+++ b/iree/compiler/Dialect/VMLA/IR/VMLADialect.cpp
@@ -54,7 +54,7 @@
 }  // namespace
 
 VMLADialect::VMLADialect(MLIRContext *context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<VMLADialect>()) {
   addInterfaces<VMLAToVMConversionInterface>();
 
   addTypes<BufferType, InterfaceType>();
diff --git a/iree/compiler/Dialect/Vulkan/IR/VulkanDialect.cpp b/iree/compiler/Dialect/Vulkan/IR/VulkanDialect.cpp
index 7a1bfd3..13ee14a 100644
--- a/iree/compiler/Dialect/Vulkan/IR/VulkanDialect.cpp
+++ b/iree/compiler/Dialect/Vulkan/IR/VulkanDialect.cpp
@@ -29,7 +29,7 @@
 static DialectRegistration<VulkanDialect> vkDialect;
 
 VulkanDialect::VulkanDialect(MLIRContext *context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<VulkanDialect>()) {
   addAttributes<TargetEnvAttr>();
 }
 
diff --git a/iree/samples/custom_modules/dialect/custom_dialect.cc b/iree/samples/custom_modules/dialect/custom_dialect.cc
index a1c8976..576b609 100644
--- a/iree/samples/custom_modules/dialect/custom_dialect.cc
+++ b/iree/samples/custom_modules/dialect/custom_dialect.cc
@@ -71,7 +71,7 @@
 }  // namespace
 
 CustomDialect::CustomDialect(MLIRContext *context)
-    : Dialect(getDialectNamespace(), context) {
+    : Dialect(getDialectNamespace(), context, TypeID::get<CustomDialect>()) {
   addInterfaces<CustomToHALConversionInterface,
                 CustomToVMConversionInterface>();
 
diff --git a/third_party/llvm-project b/third_party/llvm-project
index 9dbdaea..54cb552 160000
--- a/third_party/llvm-project
+++ b/third_party/llvm-project
@@ -1 +1 @@
-Subproject commit 9dbdaea9a0e6f58417b5bd8980e7ea6723fd1783
+Subproject commit 54cb552b962097d0e3ef7306b69a3c82cc7fff37
diff --git a/third_party/tensorflow b/third_party/tensorflow
index 0a764ff..8a4ffe2 160000
--- a/third_party/tensorflow
+++ b/third_party/tensorflow
@@ -1 +1 @@
-Subproject commit 0a764ff2fe38274592d721690cc29c5612010967
+Subproject commit 8a4ffe2e1ae722cff5306778df0cfca8b7f503fe