LLVM: lib/CodeGen/AsmPrinter/WinCFGuard.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
23
24#include
25
26using namespace llvm;
27
29
31
33
34
36 return;
37
38
40}
41
42
43
44
45
48 while (.empty()) {
49 const Value *FnOrCast = Users.pop_back_val();
50 for (const Use &U : FnOrCast->uses()) {
51 const User *FnUser = U.getUser();
52 if (isa(FnUser)) {
53
54 continue;
55 }
56 if (const auto *Call = dyn_cast(FnUser)) {
57 if ((!Call->isCallee(&U) || U.get() != F) &&
58 !Call->getFunction()->getName().ends_with("$exit_thunk")) {
59
60
61 return true;
62 }
63 } else if (isa(FnUser)) {
64
65
66
67 return true;
68 } else if (const auto *G = dyn_cast(FnUser)) {
69
70 if (G->getName() == "llvm.arm64ec.symbolmap")
71 continue;
72
73 return true;
74 } else if (isa(FnUser)) {
75
76
77 Users.push_back(FnUser);
78 }
79 }
80 }
81 return false;
82}
83
85 if (Sym->getName().starts_with("__imp_"))
86 return nullptr;
88}
89
92 std::vector<const MCSymbol *> GFIDsEntries;
93 std::vector<const MCSymbol *> GIATsEntries;
96
97
98 if (F.hasDLLImportStorageClass()) {
100 GIATsEntries.push_back(impSym);
101 }
102 }
103
104
105
106
107
108 GFIDsEntries.push_back(Asm->getSymbol(&F));
109 }
110 }
111
112 if (GFIDsEntries.empty() && GIATsEntries.empty() && LongjmpTargets.empty())
113 return;
114
115
118 for (const MCSymbol *S : GFIDsEntries)
119 OS.emitCOFFSymbolIndex(S);
120
121
123 for (const MCSymbol *S : GIATsEntries) {
124 OS.emitCOFFSymbolIndex(S);
125 }
126
127
129 for (const MCSymbol *S : LongjmpTargets) {
130 OS.emitCOFFSymbolIndex(S);
131 }
132}
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
iv Induction Variable Users
static bool isPossibleIndirectCallTarget(const Function *F)
Returns true if this function's address is escaped in a way that might make it an indirect call targe...
This class is intended to be used as a driving class for all asm writers.
MCSymbol * getSymbol(const GlobalValue *GV) const
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
MCContext & OutContext
This is the context for the output file that we are streaming.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
const MCObjectFileInfo * getObjectFileInfo() const
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
MCSection * getGFIDsSection() const
MCSection * getGLJMPSection() const
MCSection * getGIATsSection() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const std::vector< MCSymbol * > & getLongjmpTargets() const
Returns a reference to a list of symbols immediately following calls to _setjmp in the function.
const Module * getModule() const
A Module instance is used to store all the information related to an LLVM module.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
iterator_range< use_iterator > uses()
WinCFGuard(AsmPrinter *A)
void endModule() override
Emit the Control Flow Guard function ID table.
void endFunction(const MachineFunction *MF) override
Gather post-function debug information.
This is an optimization pass for GlobalISel generic memory operations.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.