23#define DEBUG_TYPE "Reader"
29 using LVDuplicateEntry = std::tuple<LVElement *, LVScope *, LVScope *>;
30 using LVDuplicate = std::vector<LVDuplicateEntry>;
31 LVDuplicate Duplicate;
33 using LVIntegrity = std::map<LVElement *, LVScope *>;
38 LVIntegrity::iterator Iter =
Integrity.find(Element);
43 Duplicate.emplace_back(Element, Scope, Iter->second);
47 std::function<void(
LVScope * Parent)> TraverseScope = [&](
LVScope *Parent) {
48 auto Traverse = [&](
const auto *Set) {
50 for (
const auto &Entry : *Set)
51 AddElement(Entry, Parent);
55 AddElement(Scope, Parent);
66 bool PassIntegrity =
true;
67 if (Duplicate.size()) {
68 std::stable_sort(begin(Duplicate), end(Duplicate),
69 [](
const auto &l,
const auto &r) {
70 return std::get<0>(l)->getID() < std::get<0>(r)->getID();
73 auto PrintIndex = [](
unsigned Index) {
79 auto PrintElement = [&](
LVElement *Element,
unsigned Index = 0) {
81 std::string ElementName(Element->
getName());
83 Element->
getID(), ElementName.c_str());
86 std::string RootName(Root->
getName());
88 dbgs() <<
format(
"Root: '%s'\nDuplicated elements: %d\n", RootName.c_str(),
93 for (
const LVDuplicateEntry &Entry : Duplicate) {
97 std::tie(Element,
First, Second) = Entry;
99 PrintElement(Element, ++Index);
101 PrintElement(Second);
104 PassIntegrity =
false;
106 return PassIntegrity;
116 Location = std::string(Where);
119 size_t Pos = Location.find_last_of(
'/');
120 if (Location.length() != Pos + 1)
121 Location.append(
"/");
133 assert(OutputFile ==
nullptr &&
"OutputFile already set.");
137 Name.append(Extension);
139 if (!Location.empty())
140 Name.insert(0, Location);
149 return std::error_code();
156 outs() <<
"Invalid instance reader.\n";
161Error LVReader::createSplitFolder() {
165 if (
options().getOutputFolder().empty())
169 SplitFolder =
options().getOutputFolder();
176 OS <<
"\nSplit View Location: '" << SplitContext.
getLocation() <<
"'\n";
187 if (CompileUnits.size()) {
189 LVCompileUnits::const_iterator Iter =
190 std::prev(CompileUnits.lower_bound(Object->getOffset()));
191 if (Iter != CompileUnits.end())
192 return Iter->second->getFilename(Index);
239 return llvm::make_error<StringError>(
"Duplicated elements in Scopes Tree",
260 if (
options().getReportExecute()) {
266 if (
options().getReportChildren() && !
options().getReportParents())
283 if (
Error Err = createSplitFolder())
287 bool DoMatch =
options().getSelectGenericPattern() ||
288 options().getSelectGenericKind() ||
289 options().getSelectOffsetPattern();
297 if (
Error Err = createSplitFolder())
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.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
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)