LLVM 19.0.0git
MachineModuleInfoImpls.cpp
Go to the documentation of this file.
1//===- llvm/CodeGen/MachineModuleInfoImpls.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//
9// This file implements object-file format specific implementations of
10// MachineModuleInfoImpl.
11//
12//===----------------------------------------------------------------------===//
13
15#include "llvm/ADT/DenseMap.h"
16#include "llvm/ADT/STLExtras.h"
17#include "llvm/MC/MCSymbol.h"
18
19using namespace llvm;
20
21//===----------------------------------------------------------------------===//
22// MachineModuleInfoMachO
23//===----------------------------------------------------------------------===//
24
25// Out of line virtual method.
26void MachineModuleInfoMachO::anchor() {}
27void MachineModuleInfoELF::anchor() {}
28void MachineModuleInfoCOFF::anchor() {}
29void MachineModuleInfoWasm::anchor() {}
30
31using PairTy = std::pair<MCSymbol *, MachineModuleInfoImpl::StubValueTy>;
32static int SortSymbolPair(const PairTy *LHS, const PairTy *RHS) {
33 return LHS->first->getName().compare(RHS->first->getName());
34}
35
38 MachineModuleInfoImpl::SymbolListTy List(Map.begin(), Map.end());
39
40 array_pod_sort(List.begin(), List.end(), SortSymbolPair);
41
42 Map.clear();
43 return List;
44}
45
46template <typename MachineModuleInfoTarget>
47static typename MachineModuleInfoTarget::AuthStubListTy getAuthGVStubListHelper(
49 &AuthPtrStubs) {
50 typename MachineModuleInfoTarget::AuthStubListTy List(AuthPtrStubs.begin(),
51 AuthPtrStubs.end());
52
53 if (!List.empty())
54 llvm::sort(List.begin(), List.end(),
55 [](const typename MachineModuleInfoTarget::AuthStubPairTy &LHS,
56 const typename MachineModuleInfoTarget::AuthStubPairTy &RHS) {
57 return LHS.first->getName() < RHS.first->getName();
58 });
59
60 AuthPtrStubs.clear();
61 return List;
62}
63
65 return getAuthGVStubListHelper<MachineModuleInfoELF>(AuthPtrStubs);
66}
This file defines the DenseMap class.
static int SortSymbolPair(const PairTy *LHS, const PairTy *RHS)
std::pair< MCSymbol *, MachineModuleInfoImpl::StubValueTy > PairTy
static MachineModuleInfoTarget::AuthStubListTy getAuthGVStubListHelper(DenseMap< MCSymbol *, typename MachineModuleInfoTarget::AuthStubInfo > &AuthPtrStubs)
This file contains some templates that are useful if you are working with the STL at all.
Value * RHS
Value * LHS
iterator begin()
Definition: DenseMap.h:75
iterator end()
Definition: DenseMap.h:84
std::vector< AuthStubPairTy > AuthStubListTy
std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy
static SymbolListTy getSortedStubs(DenseMap< MCSymbol *, StubValueTy > &)
Return the entries from a DenseMap in a deterministic sorted orer.
int compare(StringRef RHS) const
compare - Compare two strings; the result is negative, zero, or positive if this string is lexicograp...
Definition: StringRef.h:178
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1647
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
Definition: STLExtras.h:1607