24#define DEBUG_TYPE "Reader"
30 using LVDuplicateEntry = std::tuple<LVElement *, LVScope *, LVScope *>;
31 using LVDuplicate = std::vector<LVDuplicateEntry>;
32 LVDuplicate Duplicate;
34 using LVIntegrity = std::map<LVElement *, LVScope *>;
39 LVIntegrity::iterator Iter =
Integrity.find(Element);
44 Duplicate.emplace_back(Element, Scope, Iter->second);
48 std::function<void(
LVScope * Parent)> TraverseScope = [&](
LVScope *Parent) {
49 auto Traverse = [&](
const auto *Set) {
51 for (
const auto &Entry : *Set)
52 AddElement(Entry, Parent);
56 AddElement(Scope, Parent);
67 bool PassIntegrity =
true;
68 if (Duplicate.size()) {
69 std::stable_sort(begin(Duplicate), end(Duplicate),
70 [](
const auto &l,
const auto &r) {
71 return std::get<0>(l)->getID() < std::get<0>(r)->getID();
74 auto PrintIndex = [](
unsigned Index) {
82 std::string ElementName(Element->
getName());
84 Element->
getID(), ElementName.c_str());
87 std::string RootName(Root->
getName());
89 dbgs() <<
format(
"Root: '%s'\nDuplicated elements: %d\n", RootName.c_str(),
94 for (
const LVDuplicateEntry &Entry : Duplicate) {
98 std::tie(Element,
First, Second) = Entry;
100 PrintElement(Element, ++
Index);
102 PrintElement(Second);
105 PassIntegrity =
false;
107 return PassIntegrity;
117 Location = std::string(Where);
120 size_t Pos = Location.find_last_of(
'/');
121 if (Location.length() != Pos + 1)
122 Location.append(
"/");
134 assert(OutputFile ==
nullptr &&
"OutputFile already set.");
138 Name.append(Extension);
140 if (!Location.empty())
141 Name.insert(0, Location);
150 return std::error_code();
157 outs() <<
"Invalid instance reader.\n";
162Error LVReader::createSplitFolder() {
166 if (
options().getOutputFolder().empty())
170 SplitFolder =
options().getOutputFolder();
177 OS <<
"\nSplit View Location: '" << SplitContext.
getLocation() <<
"'\n";
188 if (CompileUnits.size()) {
190 LVCompileUnits::const_iterator Iter =
191 std::prev(CompileUnits.lower_bound(Object->getOffset()));
192 if (Iter != CompileUnits.end())
193 return Iter->second->getFilename(
Index);
240 return llvm::make_error<StringError>(
"Duplicated elements in Scopes Tree",
261 if (
options().getReportExecute()) {
267 if (
options().getReportChildren() && !
options().getReportParents())
284 if (
Error Err = createSplitFolder())
288 bool DoMatch =
options().getSelectGenericPattern() ||
289 options().getSelectGenericKind() ||
290 options().getSelectOffsetPattern();
298 if (
Error Err = createSplitFolder())
amdgpu AMDGPU Register Bank Select
bool checkIntegrityScopesTree(LVScope *Root)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
Stores all information relating to a compile unit, be it in its original instance in the object file ...
StringRef getName() const override
virtual const char * kind() const
void addGenericPatterns(StringSet<> &Patterns)
void updateReportOptions()
void addOffsetPatterns(const LVOffsetSet &Patterns)
The logical reader owns of all the logical elements created during the debug information parsing.
virtual void sortScopes()
void print(raw_ostream &OS) const
StringRef getFilename() const
static LVReader & getInstance()
static void setInstance(LVReader *Reader)
virtual Error printMatchedElements(bool UseMatchedElements)
virtual Error printScopes()
virtual Error createScopes()
void processRangeInformation()
Error doPrintMatches(bool Split, raw_ostream &OS, bool UseMatchedElements) const
const LVLines * getLines() const
const LVScopes * getScopes() const
const LVSymbols * getSymbols() const
const LVTypes * getTypes() const
Error doPrint(bool Split, bool Match, bool Print, raw_ostream &OS, bool Full=true) const override
std::string getLocation() const
Error createSplitFolder(StringRef Where)
std::error_code open(std::string Name, std::string Extension, raw_ostream &OS)
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::string flattenedFilePath(StringRef Path)
void make_absolute(const Twine ¤t_directory, SmallVectorImpl< char > &path)
Make path an absolute path.
std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
This is an optimization pass for GlobalISel generic memory operations.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
auto formatv(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
support::detail::RepeatAdapter< T > fmt_repeat(T &&Item, size_t Count)