IncludeGuardian updated this revision to Diff 530667.
IncludeGuardian added a comment.

Fix missing includes in test, fix formatting, and rebase on top of 
https://reviews.llvm.org/D151557


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150997/new/

https://reviews.llvm.org/D150997

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  flang/include/flang/Optimizer/HLFIR/HLFIROps.h
  llvm/include/llvm/ADT/DenseMapInfo.h
  llvm/include/llvm/CodeGen/CallingConvLower.h
  llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
  llvm/include/llvm/Object/DXContainer.h
  llvm/unittests/ADT/DenseMapTest.cpp
  mlir/include/mlir/IR/AsmState.h
  mlir/include/mlir/Transforms/SROA.h

Index: mlir/include/mlir/Transforms/SROA.h
===================================================================
--- mlir/include/mlir/Transforms/SROA.h
+++ mlir/include/mlir/Transforms/SROA.h
@@ -13,9 +13,10 @@
 #include "mlir/Interfaces/MemorySlotInterfaces.h"
 #include "mlir/Support/LogicalResult.h"
 #include "llvm/ADT/Statistic.h"
+#include <variant>

 namespace mlir {

 /// Statistics collected while applying SROA.
 struct SROAStatistics {
   /// Total amount of memory slots destructured.
Index: mlir/include/mlir/IR/AsmState.h
===================================================================
--- mlir/include/mlir/IR/AsmState.h
+++ mlir/include/mlir/IR/AsmState.h
@@ -20,20 +20,21 @@
 #include "llvm/ADT/StringMap.h"

 #include <memory>
+#include <variant>

 namespace mlir {
 class AsmResourcePrinter;
 class AsmDialectResourceHandle;
 class Operation;

 namespace detail {
 class AsmStateImpl;
 } // namespace detail

 //===----------------------------------------------------------------------===//
 // Resources
 //===----------------------------------------------------------------------===//

 /// The following classes enable support for parsing and printing resources
 /// within MLIR assembly formats. Resources are a mechanism by which dialects,
 /// and external clients, may attach additional information when parsing or
Index: llvm/unittests/ADT/DenseMapTest.cpp
===================================================================
--- llvm/unittests/ADT/DenseMapTest.cpp
+++ llvm/unittests/ADT/DenseMapTest.cpp
@@ -8,20 +8,21 @@

 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/DenseMapInfoVariant.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include <map>
 #include <set>
 #include <utility>
 #include <variant>

 using namespace llvm;

 namespace {

 uint32_t getTestKey(int i, uint32_t *) { return i; }
 uint32_t getTestValue(int i, uint32_t *) { return 42 + i; }

 uint32_t *getTestKey(int i, uint32_t **) {
   static uint32_t dummy_arr1[8192];
   assert(i < 8192 && "Only support 8192 dummy keys.");
Index: llvm/include/llvm/Object/DXContainer.h
===================================================================
--- llvm/include/llvm/Object/DXContainer.h
+++ llvm/include/llvm/Object/DXContainer.h
@@ -21,13 +21,14 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/TargetParser/Triple.h"
+#include <variant>

 namespace llvm {
 namespace object {

 namespace DirectX {
 class PSVRuntimeInfo {

   // This class provides a view into the underlying resource array. The Resource
   // data is little-endian encoded and may not be properly aligned to read
   // directly from. The dereference operator creates a copy of the data and byte
Index: llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
+++ llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
@@ -22,74 +22,75 @@
 #include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ThreadPool.h"
+#include <variant>

 namespace llvm {
 namespace orc {

 class LLJITBuilderState;
 class LLLazyJITBuilderState;
 class ObjectTransformLayer;
 class ExecutorProcessControl;

 /// A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
 ///
 /// Create instances using LLJITBuilder.
 class LLJIT {
   template <typename, typename, typename> friend class LLJITBuilderSetters;

   friend Expected<JITDylibSP> setUpGenericLLVMIRPlatform(LLJIT &J);

 public:
   /// Initializer support for LLJIT.
   class PlatformSupport {
   public:
     virtual ~PlatformSupport();

     virtual Error initialize(JITDylib &JD) = 0;

     virtual Error deinitialize(JITDylib &JD) = 0;

   protected:
     static void setInitTransform(LLJIT &J,
                                  IRTransformLayer::TransformFunction T);
   };

   /// Destruct this instance. If a multi-threaded instance, waits for all
   /// compile threads to complete.
   virtual ~LLJIT();

   /// Returns the ExecutionSession for this instance.
   ExecutionSession &getExecutionSession() { return *ES; }

   /// Returns a reference to the triple for this instance.
   const Triple &getTargetTriple() const { return TT; }

   /// Returns a reference to the DataLayout for this instance.
   const DataLayout &getDataLayout() const { return DL; }

   /// Returns a reference to the JITDylib representing the JIT'd main program.
   JITDylib &getMainJITDylib() { return *Main; }

   /// Returns the ProcessSymbols JITDylib, which by default reflects non-JIT'd
   /// symbols in the host process.
   ///
   /// Note: JIT'd code should not be added to the ProcessSymbols JITDylib. Use
   /// the main JITDylib or a custom JITDylib instead.
   JITDylibSP getProcessSymbolsJITDylib();

   /// Returns the Platform JITDylib, which will contain the ORC runtime (if
   /// given) and any platform symbols.
   ///
   /// Note: JIT'd code should not be added to the Platform JITDylib. Use the
   /// main JITDylib or a custom JITDylib instead.
   JITDylibSP getPlatformJITDylib();

   /// Returns the JITDylib with the given name, or nullptr if no JITDylib with
   /// that name exists.
   JITDylib *getJITDylibByName(StringRef Name) {
     return ES->getJITDylibByName(Name);
   }

   /// Load a (real) dynamic library and make its symbols available through a
   /// new JITDylib with the same name.
   ///
Index: llvm/include/llvm/CodeGen/CallingConvLower.h
===================================================================
--- llvm/include/llvm/CodeGen/CallingConvLower.h
+++ llvm/include/llvm/CodeGen/CallingConvLower.h
@@ -19,14 +19,15 @@
 #include "llvm/CodeGen/TargetCallingConv.h"
 #include "llvm/IR/CallingConv.h"
 #include "llvm/Support/Alignment.h"
+#include <vector>

 namespace llvm {

 class CCState;
 class MachineFunction;
 class MVT;
 class TargetRegisterInfo;

 /// CCValAssign - Represent assignment of one arg/retval to a location.
 class CCValAssign {
 public:
Index: llvm/include/llvm/ADT/DenseMapInfo.h
===================================================================
--- llvm/include/llvm/ADT/DenseMapInfo.h
+++ llvm/include/llvm/ADT/DenseMapInfo.h
@@ -20,12 +20,11 @@
 #include <tuple>
 #include <type_traits>
 #include <utility>
-#include <variant>

 namespace llvm {

 namespace detail {

 /// Simplistic combination of 32-bit hash values into 32-bit hash values.
 static inline unsigned combineHashValue(unsigned a, unsigned b) {
   uint64_t key = (uint64_t)a << 32 | (uint64_t)b;
@@ -234,24 +233,32 @@
                                     SecondInfo::getHashValue(PairVal.second));
   }

+  // Expose an additional function intended to be used by other
+  // specializations of DenseMapInfo without needing to know how
+  // to combine hash values manually
+  static unsigned getHashValuePiecewise(const T &First, const U &Second) {
+    return detail::combineHashValue(FirstInfo::getHashValue(First),
+                                    SecondInfo::getHashValue(Second));
+  }
+
   static bool isEqual(const Pair &LHS, const Pair &RHS) {
     return FirstInfo::isEqual(LHS.first, RHS.first) &&
            SecondInfo::isEqual(LHS.second, RHS.second);
   }
 };

 // Provide DenseMapInfo for all tuples whose members have info.
 template <typename... Ts> struct DenseMapInfo<std::tuple<Ts...>> {
   using Tuple = std::tuple<Ts...>;

   static inline Tuple getEmptyKey() {
     return Tuple(DenseMapInfo<Ts>::getEmptyKey()...);
   }

   static inline Tuple getTombstoneKey() {
     return Tuple(DenseMapInfo<Ts>::getTombstoneKey()...);
   }

   template <unsigned I>
   static unsigned getHashValueImpl(const Tuple &values, std::false_type) {
     using EltType = std::tuple_element_t<I, Tuple>;
@@ -290,52 +297,6 @@
   }
 };

-// Provide DenseMapInfo for variants whose all alternatives have DenseMapInfo.
-template <typename... Ts> struct DenseMapInfo<std::variant<Ts...>> {
-  using Variant = std::variant<Ts...>;
-  using FirstT = std::variant_alternative_t<0, Variant>;
-
-  static inline Variant getEmptyKey() {
-    return Variant(std::in_place_index<0>, DenseMapInfo<FirstT>::getEmptyKey());
-  }
-
-  static inline Variant getTombstoneKey() {
-    return Variant(std::in_place_index<0>,
-                   DenseMapInfo<FirstT>::getTombstoneKey());
-  }
-
-  static unsigned getHashValue(const Variant &Val) {
-    return std::visit(
-        [&Val](auto &&Alternative) {
-          using T = std::decay_t<decltype(Alternative)>;
-          // Include index in hash to make sure same value as different
-          // alternatives don't collide.
-          return detail::combineHashValue(
-              DenseMapInfo<size_t>::getHashValue(Val.index()),
-              DenseMapInfo<T>::getHashValue(Alternative));
-        },
-        Val);
-  }
-
-  static bool isEqual(const Variant &LHS, const Variant &RHS) {
-    if (LHS.index() != RHS.index())
-      return false;
-    if (LHS.valueless_by_exception())
-      return true;
-    // We want to dispatch to DenseMapInfo<T>::isEqual(LHS.get(I), RHS.get(I))
-    // We know the types are the same, but std::visit(V, LHS, RHS) doesn't.
-    // We erase the type held in LHS to void*, and dispatch over RHS.
-    const void *ErasedLHS =
-        std::visit([](const auto &LHS) -> const void * { return &LHS; }, LHS);
-    return std::visit(
-        [&](const auto &RHS) -> bool {
-          using T = std::remove_cv_t<std::remove_reference_t<decltype(RHS)>>;
-          return DenseMapInfo<T>::isEqual(*static_cast<const T *>(ErasedLHS),
-                                          RHS);
-        },
-        RHS);
-  }
-};
 } // end namespace llvm

 #endif // LLVM_ADT_DENSEMAPINFO_H
Index: flang/include/flang/Optimizer/HLFIR/HLFIROps.h
===================================================================
--- flang/include/flang/Optimizer/HLFIR/HLFIROps.h
+++ flang/include/flang/Optimizer/HLFIR/HLFIROps.h
@@ -19,9 +19,10 @@
 #include "mlir/IR/PatternMatch.h"
 #include "mlir/Interfaces/InferTypeOpInterface.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"
+#include <variant>

 #include "flang/Optimizer/HLFIR/HLFIROpInterfaces.h.inc"
 #define GET_OP_CLASSES
 #include "flang/Optimizer/HLFIR/HLFIROps.h.inc"

 #endif // FORTRAN_OPTIMIZER_HLFIR_HLFIROPS_H
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
===================================================================
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
@@ -26,12 +26,14 @@
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseMapInfoVariant.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include <memory>
 #include <utility>
+#include <variant>
 #include <vector>

 namespace llvm {
 class raw_ostream;
 } // namespace llvm
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to