Integrate llvm-project @31015240d366e4bf6f114856caa6e9ce90742b7f (#17799)

Carries the same reverts as the previous integrate
- revert

https://github.com/llvm/llvm-project/commit/2c06fb899966b49ff0fe4adf55fceb7d1941fbca
- revert

https://github.com/llvm/llvm-project/commit/fa0666876cdf11162af341911b99311a56be2274
- revert

https://github.com/llvm/llvm-project/commit/137a7451f458cf7d8e1d88df93dbd8da6888886d
diff --git a/.github/workflows/pkgci_regression_test.yml b/.github/workflows/pkgci_regression_test.yml
index c49da34..99ee321 100644
--- a/.github/workflows/pkgci_regression_test.yml
+++ b/.github/workflows/pkgci_regression_test.yml
@@ -306,7 +306,7 @@
             --goldendispatch-rocm-clip 1569 \
             --goldendispatch-rocm-vae 248 \
             --goldensize-rocm-unet-bytes 2062938 \
-            --goldensize-rocm-clip-bytes 780200 \
+            --goldensize-rocm-clip-bytes 780328 \
             --goldensize-rocm-vae-bytes 757933 \
             --gpu-number 6 \
             --rocm-chip gfx90a \
diff --git a/compiler/plugins/target/LLVMCPU/BUILD.bazel b/compiler/plugins/target/LLVMCPU/BUILD.bazel
index 71abc15..0e765fc 100644
--- a/compiler/plugins/target/LLVMCPU/BUILD.bazel
+++ b/compiler/plugins/target/LLVMCPU/BUILD.bazel
@@ -111,6 +111,7 @@
     deps = [
         "//compiler/src/iree/compiler/Utils",
         "@llvm-project//llvm:Analysis",
+        "@llvm-project//llvm:Core",
         "@llvm-project//llvm:MC",
         "@llvm-project//llvm:Passes",
         "@llvm-project//llvm:Support",
diff --git a/compiler/plugins/target/LLVMCPU/CMakeLists.txt b/compiler/plugins/target/LLVMCPU/CMakeLists.txt
index 2abea28..5d372d0 100644
--- a/compiler/plugins/target/LLVMCPU/CMakeLists.txt
+++ b/compiler/plugins/target/LLVMCPU/CMakeLists.txt
@@ -98,6 +98,7 @@
     "LLVMTargetOptions.cpp"
   DEPS
     LLVMAnalysis
+    LLVMCore
     LLVMMC
     LLVMPasses
     LLVMSupport
diff --git a/compiler/plugins/target/LLVMCPU/LLVMTargetOptions.cpp b/compiler/plugins/target/LLVMCPU/LLVMTargetOptions.cpp
index 8fe6469..b8c2513 100644
--- a/compiler/plugins/target/LLVMCPU/LLVMTargetOptions.cpp
+++ b/compiler/plugins/target/LLVMCPU/LLVMTargetOptions.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/IR/Module.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
diff --git a/compiler/plugins/target/MetalSPIRV/MSLToMetalLib.cpp b/compiler/plugins/target/MetalSPIRV/MSLToMetalLib.cpp
index 5df65ce..2937fef 100644
--- a/compiler/plugins/target/MetalSPIRV/MSLToMetalLib.cpp
+++ b/compiler/plugins/target/MetalSPIRV/MSLToMetalLib.cpp
@@ -21,8 +21,8 @@
 
 /// Returns the command to compile the given MSL source file into Metal library.
 static std::string getMetalCompileCommand(MetalTargetPlatform platform,
-                                          StringRef mslFile,
-                                          StringRef libFile) {
+                                          llvm::StringRef mslFile,
+                                          llvm::StringRef libFile) {
   const char *sdk = "";
   switch (platform) {
   case MetalTargetPlatform::macOS:
@@ -51,7 +51,7 @@
 }
 
 /// Returns the given command via system shell.
-static LogicalResult runSystemCommand(StringRef command) {
+static LogicalResult runSystemCommand(llvm::StringRef command) {
   LLVM_DEBUG(llvm::dbgs() << "Running system command: '" << command << "'\n");
   int exitCode = system(command.data());
   if (exitCode == 0)
@@ -62,9 +62,9 @@
 }
 
 std::unique_ptr<llvm::MemoryBuffer>
-compileMSLToMetalLib(MetalTargetPlatform targetPlatform, StringRef mslCode,
-                     StringRef entryPoint) {
-  SmallString<32> mslFile, airFile, libFile;
+compileMSLToMetalLib(MetalTargetPlatform targetPlatform,
+                     llvm::StringRef mslCode, llvm::StringRef entryPoint) {
+  llvm::SmallString<32> mslFile, airFile, libFile;
   int mslFd = 0;
   llvm::sys::fs::createTemporaryFile(entryPoint, "metal", mslFd, mslFile);
   llvm::sys::fs::createTemporaryFile(entryPoint, "metallib", libFile);
diff --git a/compiler/src/iree/compiler/PluginAPI/Client.h b/compiler/src/iree/compiler/PluginAPI/Client.h
index 0272e25..f9e44b8 100644
--- a/compiler/src/iree/compiler/PluginAPI/Client.h
+++ b/compiler/src/iree/compiler/PluginAPI/Client.h
@@ -61,14 +61,14 @@
   // Adds input type mnemonics that this instance supports. At least one plugin
   // must advertise support for a custom input type in order for it to be
   // considered valid.
-  virtual void populateCustomInputConversionTypes(StringSet<> &typeMnemonics) {}
+  virtual void
+  populateCustomInputConversionTypes(llvm::StringSet<> &typeMnemonics) {}
 
   // Adds input type mnemonics that this instance supports, if those types are
   // detected in |module|.
   // Requires that |registerDialects| has been called first.
-  virtual void
-  populateDetectedCustomInputConversionTypes(ModuleOp &module,
-                                             StringSet<> &typeMnemonics) {}
+  virtual void populateDetectedCustomInputConversionTypes(
+      ModuleOp &module, llvm::StringSet<> &typeMnemonics) {}
 
   // Adds passes to the input preprocessing pipeline for the given
   // InputDialectOptions::Type::plugin type with the given mnemonic.
diff --git a/compiler/src/iree/compiler/PluginAPI/PluginManager.h b/compiler/src/iree/compiler/PluginAPI/PluginManager.h
index 7f820dc..ef19499 100644
--- a/compiler/src/iree/compiler/PluginAPI/PluginManager.h
+++ b/compiler/src/iree/compiler/PluginAPI/PluginManager.h
@@ -102,14 +102,15 @@
     }
   }
 
-  void populateCustomInputConversionTypes(StringSet<> &typeMnemonics) override {
+  void populateCustomInputConversionTypes(
+      llvm::StringSet<> &typeMnemonics) override {
     for (auto *s : initializedSessions) {
       s->populateCustomInputConversionTypes(typeMnemonics);
     }
   }
 
   void populateDetectedCustomInputConversionTypes(
-      ModuleOp &module, StringSet<> &typeMnemonics) override {
+      ModuleOp &module, llvm::StringSet<> &typeMnemonics) override {
     for (auto *s : initializedSessions) {
       s->populateDetectedCustomInputConversionTypes(module, typeMnemonics);
     }
diff --git a/compiler/src/iree/compiler/Utils/OptionUtils.h b/compiler/src/iree/compiler/Utils/OptionUtils.h
index c2b5812..d972281 100644
--- a/compiler/src/iree/compiler/Utils/OptionUtils.h
+++ b/compiler/src/iree/compiler/Utils/OptionUtils.h
@@ -129,7 +129,7 @@
       -> decltype(static_cast<llvm::cl::generic_parser_base &>(parser),
                   static_cast<int>(*value), LocalOptionInfo::PrintCallback()) {
     return [optionName, &parser, value](llvm::raw_ostream &os) {
-      StringRef valueName("<unknown>");
+      llvm::StringRef valueName("<unknown>");
       for (unsigned i = 0; i < parser.getNumOptions(); ++i) {
         V cmpValue = static_cast<const llvm::cl::OptionValue<V> &>(
                          parser.getOptionValue(i))
diff --git a/third_party/llvm-project b/third_party/llvm-project
index 8ded6ce..4334375 160000
--- a/third_party/llvm-project
+++ b/third_party/llvm-project
@@ -1 +1 @@
-Subproject commit 8ded6ce55deafcad4b78ec814f1ecc80f9889392
+Subproject commit 4334375d5666c628610fc500aaab2059fd3892ba