@@ -77,13 +77,6 @@ llvm::createARMWinCOFFStreamer(MCContext &Context,
7777
7878namespace {
7979class ARMTargetWinCOFFStreamer : public llvm ::ARMTargetStreamer {
80- private:
81- // True if we are processing SEH directives in an epilogue.
82- bool InEpilogCFI = false ;
83-
84- // Symbol of the current epilog for which we are processing SEH directives.
85- MCSymbol *CurrentEpilog = nullptr ;
86-
8780public:
8881 ARMTargetWinCOFFStreamer (llvm::MCStreamer &S) : ARMTargetStreamer(S) {}
8982
@@ -114,8 +107,8 @@ void ARMTargetWinCOFFStreamer::emitARMWinUnwindCode(unsigned UnwindCode,
114107 return ;
115108 MCSymbol *Label = S.emitCFILabel ();
116109 auto Inst = WinEH::Instruction (UnwindCode, Label, Reg, Offset);
117- if (InEpilogCFI )
118- CurFrame->EpilogMap [CurrentEpilog ].Instructions .push_back (Inst);
110+ if (S. isInEpilogCFI () )
111+ CurFrame->EpilogMap [S. getCurrentEpilog () ].Instructions .push_back (Inst);
119112 else
120113 CurFrame->Instructions .push_back (Inst);
121114}
@@ -224,9 +217,10 @@ void ARMTargetWinCOFFStreamer::emitARMWinCFIEpilogStart(unsigned Condition) {
224217 if (!CurFrame)
225218 return ;
226219
227- InEpilogCFI = true ;
228- CurrentEpilog = S.emitCFILabel ();
229- CurFrame->EpilogMap [CurrentEpilog].Condition = Condition;
220+ S.emitWinCFIBeginEpilogue ();
221+ if (S.isInEpilogCFI ()) {
222+ CurFrame->EpilogMap [S.getCurrentEpilog ()].Condition = Condition;
223+ }
230224}
231225
232226void ARMTargetWinCOFFStreamer::emitARMWinCFIEpilogEnd () {
@@ -235,33 +229,26 @@ void ARMTargetWinCOFFStreamer::emitARMWinCFIEpilogEnd() {
235229 if (!CurFrame)
236230 return ;
237231
238- if (!CurrentEpilog) {
239- S.getContext ().reportError (SMLoc (), " Stray .seh_endepilogue in " +
240- CurFrame->Function ->getName ());
241- return ;
242- }
243-
244- std::vector<WinEH::Instruction> &Epilog =
245- CurFrame->EpilogMap [CurrentEpilog].Instructions ;
246-
247- unsigned UnwindCode = Win64EH::UOP_End;
248- if (!Epilog.empty ()) {
249- WinEH::Instruction EndInstr = Epilog.back ();
250- if (EndInstr.Operation == Win64EH::UOP_Nop) {
251- UnwindCode = Win64EH::UOP_EndNop;
252- Epilog.pop_back ();
253- } else if (EndInstr.Operation == Win64EH::UOP_WideNop) {
254- UnwindCode = Win64EH::UOP_WideEndNop;
255- Epilog.pop_back ();
232+ if (S.isInEpilogCFI ()) {
233+ std::vector<WinEH::Instruction> &Epilog =
234+ CurFrame->EpilogMap [S.getCurrentEpilog ()].Instructions ;
235+
236+ unsigned UnwindCode = Win64EH::UOP_End;
237+ if (!Epilog.empty ()) {
238+ WinEH::Instruction EndInstr = Epilog.back ();
239+ if (EndInstr.Operation == Win64EH::UOP_Nop) {
240+ UnwindCode = Win64EH::UOP_EndNop;
241+ Epilog.pop_back ();
242+ } else if (EndInstr.Operation == Win64EH::UOP_WideNop) {
243+ UnwindCode = Win64EH::UOP_WideEndNop;
244+ Epilog.pop_back ();
245+ }
256246 }
257- }
258247
259- InEpilogCFI = false ;
260- WinEH::Instruction Inst = WinEH::Instruction (UnwindCode, nullptr , -1 , 0 );
261- CurFrame->EpilogMap [CurrentEpilog].Instructions .push_back (Inst);
262- MCSymbol *Label = S.emitCFILabel ();
263- CurFrame->EpilogMap [CurrentEpilog].End = Label;
264- CurrentEpilog = nullptr ;
248+ WinEH::Instruction Inst = WinEH::Instruction (UnwindCode, nullptr , -1 , 0 );
249+ CurFrame->EpilogMap [S.getCurrentEpilog ()].Instructions .push_back (Inst);
250+ }
251+ S.emitWinCFIEndEpilogue ();
265252}
266253
267254void ARMTargetWinCOFFStreamer::emitARMWinCFICustom (unsigned Opcode) {
0 commit comments