LLVM: lib/CodeGen/AsmPrinter/WinCFGuard.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
22
23#include
24
25using namespace llvm;
26
28
30
32
33
35 return;
36
37
39}
40
41
42
43
44
47 while (.empty()) {
48 const Value *FnOrCast = Users.pop_back_val();
49 for (const Use &U : FnOrCast->uses()) {
50 const User *FnUser = U.getUser();
52 if ((->isCallee(&U) || U.get() != F) &&
53 ->getFunction()->getName().ends_with("$exit_thunk")) {
54
55
56 return true;
57 }
59
60
61
62 return true;
64
65 if (G->getName() == "llvm.arm64ec.symbolmap")
66 continue;
67
68 return true;
70
71
72 Users.push_back(FnUser);
73 }
74 }
75 }
76 return false;
77}
78
81 return nullptr;
82 return Asm->OutContext.lookupSymbol(Twine("__imp_") + Sym->getName());
83}
84
86 const Module *M = Asm->MMI->getModule();
87 std::vector<const MCSymbol *> GFIDsEntries;
88 std::vector<const MCSymbol *> GIATsEntries;
91
92
93 if (F.hasDLLImportStorageClass()) {
94 if (MCSymbol *impSym = lookupImpSymbol(Asm->getSymbol(&F))) {
95 GIATsEntries.push_back(impSym);
96 }
97 }
98
99
100
101
102
103 GFIDsEntries.push_back(Asm->getSymbol(&F));
104 }
105 }
106
107 if (GFIDsEntries.empty() && GIATsEntries.empty() && LongjmpTargets.empty())
108 return;
109
110
111 auto &OS = *Asm->OutStreamer;
112 OS.switchSection(Asm->OutContext.getObjectFileInfo()->getGFIDsSection());
113 for (const MCSymbol *S : GFIDsEntries)
114 OS.emitCOFFSymbolIndex(S);
115
116
117 OS.switchSection(Asm->OutContext.getObjectFileInfo()->getGIATsSection());
118 for (const MCSymbol *S : GIATsEntries) {
119 OS.emitCOFFSymbolIndex(S);
120 }
121
122
123 OS.switchSection(Asm->OutContext.getObjectFileInfo()->getGLJMPSection());
124 for (const MCSymbol *S : LongjmpTargets) {
125 OS.emitCOFFSymbolIndex(S);
126 }
127}
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
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...
Definition WinCFGuard.cpp:45
This class is intended to be used as a driving class for all asm writers.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
StringRef getName() const
getName - Get the symbol name.
const std::vector< MCSymbol * > & getLongjmpTargets() const
Returns a reference to a list of symbols immediately following calls to _setjmp in the function.
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.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
iterator_range< use_iterator > uses()
WinCFGuard(AsmPrinter *A)
Definition WinCFGuard.cpp:27
void endModule() override
Emit the Control Flow Guard function ID table.
Definition WinCFGuard.cpp:85
void endFunction(const MachineFunction *MF) override
Gather post-function debug information.
Definition WinCFGuard.cpp:31
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...