LLVM 20.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/IR/Constants.h"
18#include "llvm/IR/Module.h"
19#include "llvm/MC/MCSymbol.h"
20
21using namespace llvm;
22
23//===----------------------------------------------------------------------===//
24// MachineModuleInfoMachO
25//===----------------------------------------------------------------------===//
26
27// Out of line virtual method.
28void MachineModuleInfoMachO::anchor() {}
29void MachineModuleInfoELF::anchor() {}
30void MachineModuleInfoCOFF::anchor() {}
31void MachineModuleInfoWasm::anchor() {}
32
33using PairTy = std::pair<MCSymbol *, MachineModuleInfoImpl::StubValueTy>;
34static int SortSymbolPair(const PairTy *LHS, const PairTy *RHS) {
35 return LHS->first->getName().compare(RHS->first->getName());
36}
37
40 MachineModuleInfoImpl::SymbolListTy List(Map.begin(), Map.end());
41
42 array_pod_sort(List.begin(), List.end(), SortSymbolPair);
43
44 Map.clear();
45 return List;
46}
47
48using ExprStubPairTy = std::pair<MCSymbol *, const MCExpr *>;
49static int SortAuthStubPair(const ExprStubPairTy *LHS,
50 const ExprStubPairTy *RHS) {
51 return LHS->first->getName().compare(RHS->first->getName());
52}
53
57 ExprStubs.end());
58
60
61 ExprStubs.clear();
62 return List;
63}
64
66 const Module *M = MMI.getModule();
67 const auto *Flag = mdconst::extract_or_null<ConstantInt>(
68 M->getModuleFlag("ptrauth-sign-personality"));
69 HasSignedPersonality = Flag && Flag->getZExtValue() == 1;
70}
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
Module.h This file contains the declarations for the Module class.
static int SortSymbolPair(const PairTy *LHS, const PairTy *RHS)
std::pair< MCSymbol *, const MCExpr * > ExprStubPairTy
std::pair< MCSymbol *, MachineModuleInfoImpl::StubValueTy > PairTy
static int SortAuthStubPair(const ExprStubPairTy *LHS, const ExprStubPairTy *RHS)
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
MachineModuleInfoELF(const MachineModuleInfo &)
std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy
static SymbolListTy getSortedStubs(DenseMap< MCSymbol *, StubValueTy > &)
Return the entries from a DenseMap in a deterministic sorted orer.
std::vector< std::pair< MCSymbol *, const MCExpr * > > ExprStubListTy
A variant of SymbolListTy where the stub is a generalized MCExpr.
static ExprStubListTy getSortedExprStubs(DenseMap< MCSymbol *, const MCExpr * > &)
Return the entries from a DenseMap in a deterministic sorted orer.
This class contains meta information specific to a module.
const Module * getModule() const
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
int compare(StringRef RHS) const
compare - Compare two strings; the result is negative, zero, or positive if this string is lexicograp...
Definition: StringRef.h:183
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 array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
Definition: STLExtras.h:1624