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 #include +#include #include namespace llvm { class raw_ostream; } // namespace llvm 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 #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: llvm/include/llvm/ADT/DenseMapInfo.h =================================================================== --- llvm/include/llvm/ADT/DenseMapInfo.h +++ llvm/include/llvm/ADT/DenseMapInfo.h @@ -20,12 +20,11 @@ #include #include #include -#include 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 struct DenseMapInfo> { using Tuple = std::tuple; static inline Tuple getEmptyKey() { return Tuple(DenseMapInfo::getEmptyKey()...); } static inline Tuple getTombstoneKey() { return Tuple(DenseMapInfo::getTombstoneKey()...); } template static unsigned getHashValueImpl(const Tuple &values, std::false_type) { using EltType = std::tuple_element_t; @@ -290,52 +297,6 @@ } }; -// Provide DenseMapInfo for variants whose all alternatives have DenseMapInfo. -template struct DenseMapInfo> { - using Variant = std::variant; - using FirstT = std::variant_alternative_t<0, Variant>; - - static inline Variant getEmptyKey() { - return Variant(std::in_place_index<0>, DenseMapInfo::getEmptyKey()); - } - - static inline Variant getTombstoneKey() { - return Variant(std::in_place_index<0>, - DenseMapInfo::getTombstoneKey()); - } - - static unsigned getHashValue(const Variant &Val) { - return std::visit( - [&Val](auto &&Alternative) { - using T = std::decay_t; - // Include index in hash to make sure same value as different - // alternatives don't collide. - return detail::combineHashValue( - DenseMapInfo::getHashValue(Val.index()), - DenseMapInfo::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::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>; - return DenseMapInfo::isEqual(*static_cast(ErasedLHS), - RHS); - }, - RHS); - } -}; } // end namespace llvm #endif // LLVM_ADT_DENSEMAPINFO_H Index: llvm/include/llvm/ADT/DenseMapInfoVariant.h =================================================================== --- /dev/null +++ llvm/include/llvm/ADT/DenseMapInfoVariant.h @@ -0,0 +1,71 @@ +//===- DenseMapInfoVariant.h - Type traits for DenseMap *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// This file defines DenseMapInfo traits for DenseMap>. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_DENSEMAPINFOVARIANT_H +#define LLVM_ADT_DENSEMAPINFOVARIANT_H + +#include "llvm/ADT/DenseMapInfo.h" +#include +#include + +namespace llvm { + +// Provide DenseMapInfo for variants whose all alternatives have DenseMapInfo. +template struct DenseMapInfo> { + using Variant = std::variant; + using FirstT = std::variant_alternative_t<0, Variant>; + + static inline Variant getEmptyKey() { + return Variant(std::in_place_index<0>, DenseMapInfo::getEmptyKey()); + } + + static inline Variant getTombstoneKey() { + return Variant(std::in_place_index<0>, + DenseMapInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const Variant &Val) { + return std::visit( + [&Val](auto &&Alternative) { + using T = std::decay_t; + // Include index in hash to make sure same value as different + // alternatives don't collide. + return DenseMapInfo>::getHashValuePiecewise( + Val.index(), 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::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>; + return DenseMapInfo::isEqual(*static_cast(ErasedLHS), + RHS); + }, + RHS); + } +}; + +} // end namespace llvm + +#endif // LLVM_ADT_DENSEMAPINFOVARIANT_H Index: llvm/include/llvm/CodeGen/CallingConvLower.h =================================================================== --- llvm/include/llvm/CodeGen/CallingConvLower.h +++ llvm/include/llvm/CodeGen/CallingConvLower.h @@ -19,14 +19,16 @@ #include "llvm/CodeGen/TargetCallingConv.h" #include "llvm/IR/CallingConv.h" #include "llvm/Support/Alignment.h" +#include +#include 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/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 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 friend class LLJITBuilderSetters; friend Expected 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/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 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/Transforms/Scalar/SROA.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/SROA.h +++ llvm/include/llvm/Transforms/Scalar/SROA.h @@ -21,10 +21,11 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/IR/PassManager.h" #include "llvm/IR/ValueHandle.h" +#include #include namespace llvm { class AllocaInst; class LoadInst; class StoreInst; 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 #include #include #include 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: 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 +#include 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: 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 namespace mlir { /// Statistics collected while applying SROA. struct SROAStatistics { /// Total amount of memory slots destructured.