LLVM: lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
25using namespace llvm;
26
28
30
31void DwarfCFIException::addPersonality(const GlobalValue *Personality) {
33 Personalities.push_back(Personality);
34}
35
36
37
39
40 if (->MAI->usesCFIForEH())
41 return;
42
44
46
48 return;
49
50
51 for (const GlobalValue *Personality : Personalities) {
52 MCSymbol *Sym = Asm->getSymbol(Personality);
54 Asm->MMI);
55 }
56 Personalities.clear();
57}
58
60 shouldEmitPersonality = shouldEmitLSDA = false;
62
63
65
66
67 bool shouldEmitMoves =
69
73 if (F.hasPersonalityFn())
75
76
77 forceEmitPersonality =
78
79 F.hasPersonalityFn() &&
80
82
83 F.needsUnwindTableEntry();
84
85 shouldEmitPersonality =
86 (forceEmitPersonality ||
88 Per;
89
91 shouldEmitLSDA = shouldEmitPersonality &&
93
96 shouldEmitCFI =
97 MAI.usesCFIForEH() && (shouldEmitPersonality || shouldEmitMoves);
98 else
99 shouldEmitCFI = Asm->usesCFIWithoutEH() && shouldEmitMoves;
100}
101
103 if (!shouldEmitCFI)
104 return;
105
106 if (!hasEmittedCFISections) {
108
109
110
112 Asm->TM.Options.ForceDwarfFrameSection ||
113 Asm->TM.Options.MCOptions.EmitSFrameUnwind)
114 Asm->OutStreamer->emitCFISections(
116 Asm->TM.Options.MCOptions.EmitSFrameUnwind);
117 hasEmittedCFISections = true;
118 }
119
120 Asm->OutStreamer->emitCFIStartProc(false);
121
122
123 if (!shouldEmitPersonality)
124 return;
125
126 auto &F = MBB.getParent()->getFunction();
128 assert(P && "Expected personality function");
129
130 addPersonality(P);
131
135 Asm->OutStreamer->emitCFIPersonality(Sym, PerEncoding);
136
137
138 if (shouldEmitLSDA)
139 Asm->OutStreamer->emitCFILsda(Asm->getMBBExceptionSym(MBB),
141}
142
144 if (shouldEmitCFI)
145 Asm->OutStreamer->emitCFIEndProc();
146}
147
148
149
151 if (!shouldEmitPersonality)
152 return;
153
155}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file contains constants used for implementing Dwarf debug support.
This class is intended to be used as a driving class for all asm writers.
@ None
Do not emit either .eh_frame or .debug_frame.
@ Debug
Emit .debug_frame.
void endBasicBlockSection(const MachineBasicBlock &MBB) override
Process the end of a basic-block-section within a function.
Definition DwarfCFIException.cpp:143
~DwarfCFIException() override
void beginBasicBlockSection(const MachineBasicBlock &MBB) override
Process the beginning of a new basic-block-section within a function.
Definition DwarfCFIException.cpp:102
void endFunction(const MachineFunction *) override
Gather and emit post-function exception information.
Definition DwarfCFIException.cpp:150
void endModule() override
Emit all exception information that should come after the content.
Definition DwarfCFIException.cpp:38
DwarfCFIException(AsmPrinter *A)
Definition DwarfCFIException.cpp:27
void beginFunction(const MachineFunction *MF) override
Gather pre-function exception information.
Definition DwarfCFIException.cpp:59
AsmPrinter * Asm
Target of directive emission.
MCSymbol * emitExceptionTable()
Emit landing pads and actions.
MachineModuleInfo * MMI
Collected machine module information.
EHStreamer(AsmPrinter *A)
This class is intended to be used as a base class for asm properties and features specific to the tar...
bool usesCFIForEH() const
Returns true if the exception handling method for the platform uses call frame information to unwind.
ExceptionHandling getExceptionHandlingType() const
const MCAsmInfo * getAsmInfo() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCContext & getContext() const
Function & getFunction()
Return the LLVM function that this machine code represents.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
unsigned getLSDAEncoding() const
virtual MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const
unsigned getPersonalityEncoding() const
virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM, const MCSymbol *Sym, const MachineModuleInfo *MMI) const
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.
@ None
No exception support.
bool isNoOpWithoutInvoke(EHPersonality Pers)
Return true if this personality may be safely removed if there are no invoke instructions remaining i...
LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.