This is an archive of the discontinued LLVM Phabricator instance.

[BOLT][Instrumentation] Instrument leaves from spanning tree
AbandonedPublic

Authored by yavtuk on Nov 8 2022, 12:42 AM.

Details

Summary

For non-conservative instrumentation mode we should insert an instrumentation snippet from STOutSet.
Otherwise, the check size() == 0 makes no sense, because if there is no BB in STOutSet then the default constructor is called and
this BB is added with zero size of successors set.
And it means that we insert an instrumentation snippet to all BBs that originally filtered when constructing the spanning tree.

Diff Detail

Event Timeline

yavtuk created this revision.Nov 8 2022, 12:42 AM
Herald added a reviewer: Amir. · View Herald Transcript
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
yavtuk requested review of this revision.Nov 8 2022, 12:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 12:42 AM

@rafauler @Amir @maksfb Hi folks, what do you thought? Does it make sense?

Hi @yavtuk! Thanks for the patch.

I was on leave and couldn't get to it earlier, sorry about that.

And it means that we insert an instrumentation snippet to all BBs that originally filtered when constructing the spanning tree.

Here, what do you mean by BBs originally filtered? I might be missing something, so I'll tell you what I know about this code and you correct me if I'm wrong. It is true that this code currently inserts an empty std::set for elements not in STOutSet and triggers the condition that instruments this basic block. So any blocks not in STOutSet will be instrumented. But this is by design, the idea being that we may only omit instrumentation in specific cases, when the node is part of the spanning tree and not a leaf. In these cases, the node will be in STOutSet and we will skip adding instrumentation code to it.

Hi Rafael, welcome back, give me some time to remember why I decided so, I’ll be back with an example soon.
Maybe I just misunderstood what’s meant by a non-conservative algorithm

@rafauler you’re right, thanks for explanation.
I was confused by the following checking

if (STOutSet[&BB].size() == 0)

Because if for some reason the BB is not in the spanning tree, the default constructor for this base block is called and it is inserted into the STOutSet with 0 number of successros.
Therefore the insturmentation snipet is inserted.
But now there is only one reason for that, a BB is a tree leaf.

yavtuk abandoned this revision.Jan 12 2023, 3:30 AM