Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bolt/lib/Profile/DataAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ DataAggregator::writeAggregatedFile(StringRef OutputFilename) const {
OutFile << "boltedcollection\n";
if (opts::BasicAggregation) {
OutFile << "no_lbr";
for (const StringMapEntry<std::nullopt_t> &Entry : EventNames)
for (const StringMapEntry<EmptyStringSetTag> &Entry : EventNames)
OutFile << " " << Entry.getKey();
OutFile << "\n";

Expand Down Expand Up @@ -2291,7 +2291,7 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,

ListSeparator LS(",");
raw_string_ostream EventNamesOS(BP.Header.EventNames);
for (const StringMapEntry<std::nullopt_t> &EventEntry : EventNames)
for (const StringMapEntry<EmptyStringSetTag> &EventEntry : EventNames)
EventNamesOS << LS << EventEntry.first().str();

BP.Header.Flags = opts::BasicAggregation ? BinaryFunction::PF_BASIC
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Profile/YAMLProfileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ std::error_code YAMLProfileWriter::writeProfile(const RewriteInstance &RI) {
StringSet<> EventNames = RI.getProfileReader()->getEventNames();
if (!EventNames.empty()) {
std::string Sep;
for (const StringMapEntry<std::nullopt_t> &EventEntry : EventNames) {
for (const StringMapEntry<EmptyStringSetTag> &EventEntry : EventNames) {
BP.Header.EventNames += Sep + EventEntry.first().str();
Sep = ",";
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/ADT/StringMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap
if (FindInRHS == RHS.end())
return false;

if constexpr (!std::is_same_v<ValueTy, std::nullopt_t>) {
if constexpr (!std::is_same_v<ValueTy, EmptyStringSetTag>) {
if (!(KeyValue.getValue() == FindInRHS->getValue()))
return false;
}
Expand Down
10 changes: 6 additions & 4 deletions llvm/include/llvm/ADT/StringMapEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

namespace llvm {

/// The "value type" of StringSet represented as an empty struct.
struct EmptyStringSetTag {};

/// StringMapEntryBase - Shared base class of StringMapEntry instances.
class StringMapEntryBase {
size_t keyLength;
Expand Down Expand Up @@ -85,14 +88,13 @@ class StringMapEntryStorage : public StringMapEntryBase {
};

template <>
class StringMapEntryStorage<std::nullopt_t> : public StringMapEntryBase {
class StringMapEntryStorage<EmptyStringSetTag> : public StringMapEntryBase {
public:
explicit StringMapEntryStorage(size_t keyLength,
std::nullopt_t = std::nullopt)
explicit StringMapEntryStorage(size_t keyLength, EmptyStringSetTag = {})
: StringMapEntryBase(keyLength) {}
StringMapEntryStorage(StringMapEntryStorage &entry) = delete;

std::nullopt_t getValue() const { return std::nullopt; }
EmptyStringSetTag getValue() const { return {}; }
};

/// StringMapEntry - This is used to represent one value that is inserted into
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/ADT/StringSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace llvm {

/// StringSet - A wrapper for StringMap that provides set-like functionality.
template <class AllocatorTy = MallocAllocator>
class StringSet : public StringMap<std::nullopt_t, AllocatorTy> {
using Base = StringMap<std::nullopt_t, AllocatorTy>;
class StringSet : public StringMap<EmptyStringSetTag, AllocatorTy> {
using Base = StringMap<EmptyStringSetTag, AllocatorTy>;

public:
StringSet() = default;
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DWARFLinker/StringPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace dwarf_linker {

/// StringEntry keeps data of the string: the length, external offset
/// and a string body which is placed right after StringEntry.
using StringEntry = StringMapEntry<std::nullopt_t>;
using StringEntry = StringMapEntry<EmptyStringSetTag>;

class StringPoolEntryInfo {
public:
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Support/Timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DefaultTimingManagerImpl;
/// This is a POD type with pointer size, so it should be passed around by
/// value. The underlying data is owned by the `TimingManager`.
class TimingIdentifier {
using EntryType = llvm::StringMapEntry<std::nullopt_t>;
using EntryType = llvm::StringMapEntry<llvm::EmptyStringSetTag>;

public:
TimingIdentifier(const TimingIdentifier &) = default;
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Support/Timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class TimingManagerImpl {
llvm::sys::SmartRWMutex<true> identifierMutex;

/// A thread local cache of identifiers to reduce lock contention.
ThreadLocalCache<llvm::StringMap<llvm::StringMapEntry<std::nullopt_t> *>>
ThreadLocalCache<
llvm::StringMap<llvm::StringMapEntry<llvm::EmptyStringSetTag> *>>
localIdentifierCache;

TimingManagerImpl() : identifiers(identifierAllocator) {}
Expand Down