LLVM 19.0.0git
NonRelocatableStringpool.cpp
Go to the documentation of this file.
1//===-- NonRelocatableStringpool.cpp --------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/ADT/STLExtras.h"
11
12namespace llvm {
13
15 auto I = Strings.insert({S, DwarfStringPoolEntry()});
16 auto &Entry = I.first->second;
17 if (I.second || !Entry.isIndexed()) {
18 Entry.Index = NumEntries++;
19 Entry.Offset = CurrentEndOffset;
20 Entry.Symbol = nullptr;
21 CurrentEndOffset += S.size() + 1;
22 }
23 return DwarfStringPoolEntryRef(*I.first);
24}
25
28
29 auto InsertResult = Strings.insert({S, Entry});
30 return InsertResult.first->getKey();
31}
32
33std::vector<DwarfStringPoolEntryRef>
35 std::vector<DwarfStringPoolEntryRef> Result;
36 Result.reserve(Strings.size());
37 for (const auto &E : Strings)
38 if (E.getValue().isIndexed())
39 Result.emplace_back(E);
40 llvm::sort(Result, [](const DwarfStringPoolEntryRef A,
42 return A.getIndex() < B.getIndex();
43 });
44 return Result;
45}
46
47} // namespace llvm
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define I(x, y, z)
Definition: MD5.cpp:58
This file contains some templates that are useful if you are working with the STL at all.
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
DwarfStringPoolEntryRef getEntry(StringRef S)
std::vector< DwarfStringPoolEntryRef > getEntriesForEmission() const
Return the list of strings to be emitted.
StringRef internString(StringRef S)
Get permanent storage for S (but do not necessarily emit S in the output section).
unsigned size() const
Definition: StringMap.h:104
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:307
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1656
Data for a string pool entry.
static constexpr unsigned NotIndexed