-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[StandardInstrumentations]Add support for numeric label #148844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
aa2a56a
88a7e60
5284f4f
2e1454c
f17e0de
51adaaf
e3d8ff2
89f7436
1632fae
df906f3
2f333d6
f099b2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -727,8 +727,13 @@ template <typename T> | |
template <typename FunctionT> | ||
bool IRComparer<T>::generateFunctionData(IRDataT<T> &Data, const FunctionT &F) { | ||
if (shouldGenerateData(F)) { | ||
FuncDataT<T> FD(F.front().getName().str()); | ||
int I = 0; | ||
// Basic block with numberic label will be empty here. | ||
std::string FDEntryBlockName = F.front().getName().str(); | ||
if (FDEntryBlockName.empty()) | ||
FDEntryBlockName = formatv("{0}", I); | ||
|
||
FuncDataT<T> FD(FDEntryBlockName); | ||
for (const auto &B : F) { | ||
std::string BBName = B.getName().str(); | ||
if (BBName.empty()) { | ||
|
@@ -1791,10 +1796,10 @@ class DotCfgDiffNode { | |
// Create a node in Dot difference graph \p G representing the basic block | ||
// represented by \p BD with colour \p Colour (where it exists). | ||
DotCfgDiffNode(DotCfgDiff &G, unsigned N, const BlockDataT<DCData> &BD, | ||
StringRef Colour) | ||
: Graph(G), N(N), Data{&BD, nullptr}, Colour(Colour) {} | ||
StringRef Label, StringRef Colour) | ||
: Graph(G), N(N), Data{&BD, nullptr}, Label(Label), Colour(Colour) {} | ||
DotCfgDiffNode(const DotCfgDiffNode &DN) | ||
: Graph(DN.Graph), N(DN.N), Data{DN.Data[0], DN.Data[1]}, | ||
: Graph(DN.Graph), N(DN.N), Data{DN.Data[0], DN.Data[1]}, Label(DN.Label), | ||
Colour(DN.Colour), EdgesMap(DN.EdgesMap), Children(DN.Children), | ||
Edges(DN.Edges) {} | ||
|
||
|
@@ -1803,6 +1808,8 @@ class DotCfgDiffNode { | |
// The label of the basic block | ||
StringRef getLabel() const { | ||
assert(Data[0] && "Expected Data[0] to be set."); | ||
assert((Data[0]->getLabel().empty() || Data[0]->getLabel() == Label) && | ||
"Unexpected label"); | ||
jamieschmeiser marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
return Data[0]->getLabel(); | ||
} | ||
// Return the colour for this block | ||
|
@@ -1840,6 +1847,7 @@ class DotCfgDiffNode { | |
DotCfgDiff &Graph; | ||
const unsigned N; | ||
const BlockDataT<DCData> *Data[2]; | ||
StringRef Label; | ||
StringRef Colour; | ||
std::map<const unsigned, std::pair<std::string, StringRef>> EdgesMap; | ||
std::vector<unsigned> Children; | ||
|
@@ -1888,7 +1896,7 @@ class DotCfgDiff { | |
|
||
void createNode(StringRef Label, const BlockDataT<DCData> &BD, StringRef C) { | ||
unsigned Pos = Nodes.size(); | ||
Nodes.emplace_back(*this, Pos, BD, C); | ||
Nodes.emplace_back(*this, Pos, BD, Label, C); | ||
NodePosition.insert({Label, Pos}); | ||
} | ||
|
||
|
@@ -1950,10 +1958,9 @@ std::string DotCfgDiffNode::getBodyContent() const { | |
// Drop leading newline, if present. | ||
if (BS.front() == '\n') | ||
BS1 = BS1.drop_front(1); | ||
// Get label. | ||
StringRef Label = BS1.take_until([](char C) { return C == ':'; }); | ||
// drop predecessors as they can be big and are redundant | ||
BS1 = BS1.drop_until([](char C) { return C == '\n'; }).drop_front(); | ||
if (BS1.str().find(Label) != std::string::npos) | ||
|
||
BS1 = BS1.drop_until([](char C) { return C == '\n'; }).drop_front(); | ||
|
||
std::string S = "<FONT COLOR=\"" + Colour.str() + "\">" + Label.str() + ":"; | ||
|
||
|
@@ -1995,6 +2002,11 @@ DotCfgDiff::DotCfgDiff(StringRef Title, const FuncDataT<DCData> &Before, | |
EdgesMap.insert({Key, BeforeColour}); | ||
} | ||
} | ||
if (Before == After) { | ||
for (auto &I : Nodes) | ||
I.finalize(*this); | ||
return; | ||
} | ||
|
||
// Handle each basic block in the after IR | ||
for (auto &A : After.getData()) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.