LLVM 19.0.0git
LVCompare.h
Go to the documentation of this file.
1//===-- LVCompare.h ---------------------------------------------*- C++ -*-===//
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// This file defines the LVCompare class, which is used to describe a logical
10// view comparison.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVCOMPARE_H
15#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVCOMPARE_H
16
18
19namespace llvm {
20namespace logicalview {
21
22class LVReader;
23
24// Record the elements missing or added and their compare pass.
25using LVPassEntry = std::tuple<LVReader *, LVElement *, LVComparePass>;
26using LVPassTable = std::vector<LVPassEntry>;
27
28class LVCompare final {
29 raw_ostream &OS;
30 LVScopes ScopeStack;
31
32 // As the comparison is performed twice (by exchanging the reference
33 // and target readers) the element missing/added status does specify
34 // the comparison pass.
35 // By recording each missing/added elements along with its pass, it
36 // allows checking which elements were missing/added during each pass.
37 LVPassTable PassTable;
38
39 // Reader used on the LHS of the comparison.
40 // In the 'Missing' pass, it points to the reference reader.
41 // In the 'Added' pass it points to the target reader.
42 LVReader *Reader = nullptr;
43
44 bool FirstMissing = true;
45 bool PrintLines = false;
46 bool PrintScopes = false;
47 bool PrintSymbols = false;
48 bool PrintTypes = false;
49
50 static void setInstance(LVCompare *Compare);
51
52 void printCurrentStack();
53 void printSummary() const;
54
55public:
56 LVCompare() = delete;
58 LVCompare(const LVCompare &) = delete;
59 LVCompare &operator=(const LVCompare &) = delete;
60 ~LVCompare() = default;
61
62 static LVCompare &getInstance();
63
64 // Scopes stack used during the missing/added reporting.
65 void push(LVScope *Scope) { ScopeStack.push_back(Scope); }
66 void pop() { ScopeStack.pop_back(); }
67
68 // Perform comparison between the 'Reference' and 'Target' scopes tree.
69 Error execute(LVReader *ReferenceReader, LVReader *TargetReader);
70
72 PassTable.emplace_back(Reader, Element, Pass);
73 }
74 const LVPassTable &getPassTable() const & { return PassTable; }
75
76 void printItem(LVElement *Element, LVComparePass Pass);
77 void print(raw_ostream &OS) const;
78
79#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
80 void dump() const { print(dbgs()); }
81#endif
82};
83
85
86} // end namespace logicalview
87} // end namespace llvm
88
89#endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVCOMPARE_H
aarch64 promote const
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
void push_back(const T &Elt)
Definition: SmallVector.h:426
void print(raw_ostream &OS) const
Definition: LVCompare.cpp:427
void printItem(LVElement *Element, LVComparePass Pass)
Definition: LVCompare.cpp:361
LVCompare(const LVCompare &)=delete
static LVCompare & getInstance()
Definition: LVCompare.cpp:101
LVCompare & operator=(const LVCompare &)=delete
const LVPassTable & getPassTable() const &
Definition: LVCompare.h:74
void push(LVScope *Scope)
Definition: LVCompare.h:65
Error execute(LVReader *ReferenceReader, LVReader *TargetReader)
Definition: LVCompare.cpp:118
void addPassEntry(LVReader *Reader, LVElement *Element, LVComparePass Pass)
Definition: LVCompare.h:71
The logical reader owns of all the logical elements created during the debug information parsing.
Definition: LVReader.h:60
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
std::tuple< LVReader *, LVElement *, LVComparePass > LVPassEntry
Definition: LVCompare.h:25
std::vector< LVPassEntry > LVPassTable
Definition: LVCompare.h:26
LVCompare & getComparator()
Definition: LVCompare.h:84
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163