1 //===----------------------------------------------------------------------===//
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 #include "llvm/DWARFCFIChecker/DWARFCFIFunctionFrameAnalyzer.h"
10
11 using namespace llvm;
12
~CFIFunctionFrameAnalyzer()13 CFIFunctionFrameAnalyzer::~CFIFunctionFrameAnalyzer() {
14 assert(UIAs.empty() &&
15 "all frames should be closed before the analysis finishes");
16 }
17
startFunctionFrame(bool IsEH,ArrayRef<MCCFIInstruction> Prologue)18 void CFIFunctionFrameAnalyzer::startFunctionFrame(
19 bool IsEH, ArrayRef<MCCFIInstruction> Prologue) {
20 UIAs.emplace_back(&getContext(), MCII, IsEH, Prologue);
21 }
22
emitInstructionAndDirectives(const MCInst & Inst,ArrayRef<MCCFIInstruction> Directives)23 void CFIFunctionFrameAnalyzer::emitInstructionAndDirectives(
24 const MCInst &Inst, ArrayRef<MCCFIInstruction> Directives) {
25 assert(!UIAs.empty() && "if the instruction is in a frame, there should be "
26 "a analysis instantiated for it");
27 UIAs.back().update(Inst, Directives);
28 }
29
finishFunctionFrame()30 void CFIFunctionFrameAnalyzer::finishFunctionFrame() {
31 assert(!UIAs.empty() && "there should be an analysis for each frame");
32 UIAs.pop_back();
33 }
34