-
Notifications
You must be signed in to change notification settings - Fork 74
Display origin of template instantiations #105
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
Open
vittorioromeo
wants to merge
6
commits into
aras-p:main
Choose a base branch
from
vittorioromeo:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2cb15b4
Display origin of template instantiations
vittorioromeo 756b7ca
Sort template instantiation sources by count
vittorioromeo 8c0ba66
Actually print what I sorted
vittorioromeo 50ca913
Change ini defaults
vittorioromeo 5eafab1
Adjust defaults to match ini
vittorioromeo fe1dd44
Remove stray char
vittorioromeo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,8 +215,10 @@ struct BuildEventsParser | |
| BuildEvent& ev = resultEvents[EventIndex(int(i))]; | ||
| if (ev.parent.idx >= 0) | ||
| ev.parent.idx += offset; | ||
|
|
||
| for (auto& ch : ev.children) | ||
| ch.idx += offset; | ||
|
|
||
| if (ev.detailIndex.idx != 0) | ||
| { | ||
| assert(ev.detailIndex.idx >= 0); | ||
|
|
@@ -225,6 +227,15 @@ struct BuildEventsParser | |
| assert(ev.detailIndex.idx >= 0); | ||
| assert(ev.detailIndex.idx < static_cast<int>(resultNameToIndex.size())); | ||
| } | ||
|
|
||
| if (ev.filenameDetailIndex.idx != 0) | ||
| { | ||
| assert(ev.filenameDetailIndex.idx >= 0); | ||
| assert(ev.filenameDetailIndex.idx < static_cast<int>(nameToIndex.size())); | ||
| ev.filenameDetailIndex = detailRemap[ev.filenameDetailIndex]; | ||
| assert(ev.filenameDetailIndex.idx >= 0); | ||
| assert(ev.filenameDetailIndex.idx < static_cast<int>(resultNameToIndex.size())); | ||
| } | ||
|
Comment on lines
+231
to
+238
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way we can avoid adding the extra field? |
||
| } | ||
|
|
||
| assert(resultNameToIndex.size() == resultNames.size()); | ||
|
|
@@ -321,6 +332,7 @@ struct BuildEventsParser | |
| BuildEvent event; | ||
| bool valid = true; | ||
| std::string_view detailPtr; | ||
| std::string_view filenameDetailPtr; | ||
| for (const simdjson::dom::key_value_pair& kv : node) | ||
| { | ||
| std::string_view nodeKey = kv.key; | ||
|
|
@@ -400,20 +412,20 @@ struct BuildEventsParser | |
| if (event.type== BuildEventType::kUnknown || !valid) | ||
| return; | ||
|
|
||
| // if the "compiler" event has no detail name, use the current json file name | ||
| if (detailPtr.empty() && event.type == BuildEventType::kCompiler) | ||
| detailPtr = curFileName; | ||
| if (!detailPtr.empty()) | ||
| const auto processDetail = [this, &event, &nameToIndexLocal](std::string_view& theDetailPtr) -> DetailIndex | ||
| { | ||
| if (theDetailPtr.empty()) | ||
| return DetailIndex{}; | ||
|
|
||
| std::string detailString; | ||
| if (event.type == BuildEventType::kParseFile || event.type == BuildEventType::kOptModule) | ||
| { | ||
| // do various cleanups/nice-ifications of the detail name: | ||
| // make paths shorter (i.e. relative to project) where possible | ||
| detailString = utils::GetNicePath(detailPtr); | ||
| detailString = utils::GetNicePath(theDetailPtr); | ||
| } | ||
| else | ||
| detailString = detailPtr; | ||
| detailString = theDetailPtr; | ||
|
|
||
| // don't report the clang trace .json file, instead get the object file at the same location if it's there | ||
| if (utils::EndsWith(detailString, ".json")) | ||
|
|
@@ -435,8 +447,20 @@ struct BuildEventsParser | |
| if (event.type == BuildEventType::kOptFunction) | ||
| detailString = llvm::demangle(detailString); | ||
|
|
||
| event.detailIndex = NameToIndex(detailString.c_str(), nameToIndexLocal); | ||
| } | ||
| return NameToIndex(detailString.c_str(), nameToIndexLocal); | ||
| }; | ||
|
|
||
| // if the "compiler" event has no detail name, use the current json file name | ||
| if (detailPtr.empty() && event.type == BuildEventType::kCompiler) | ||
| detailPtr = curFileName; | ||
|
|
||
| event.detailIndex = processDetail(detailPtr); | ||
|
|
||
| // use the current json file name for the "instantiateX" event filename detail | ||
| if (event.type == BuildEventType::kInstantiateClass || event.type == BuildEventType::kInstantiateFunction) | ||
| filenameDetailPtr = curFileName; | ||
|
Comment on lines
+459
to
+461
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get more precise information other than the event filename, somehow? |
||
|
|
||
| event.filenameDetailIndex = processDetail(filenameDetailPtr); | ||
|
|
||
| // starting with clang 19, some Source events are pairs of "b" immediately followed | ||
| // by "e" events. Handle merging of those if needed; do not support other cases of | ||
|
|
@@ -610,6 +634,7 @@ bool SaveBuildEvents(BuildEventsParser* parser, const std::string& fileName) | |
| w.Write(e.ts); | ||
| w.Write(e.dur); | ||
| w.Write(e.detailIndex.idx); | ||
| w.Write(e.filenameDetailIndex.idx); | ||
| w.Write(e.parent.idx); | ||
| int64_t childCount = e.children.size(); | ||
| w.Write(childCount); | ||
|
|
@@ -670,6 +695,7 @@ bool LoadBuildEvents(const std::string& fileName, BuildEvents& outEvents, BuildN | |
| r.Read(e.ts); | ||
| r.Read(e.dur); | ||
| r.Read(e.detailIndex.idx); | ||
| r.Read(e.filenameDetailIndex.idx); | ||
| r.Read(e.parent.idx); | ||
| int64_t childCount = 0; | ||
| r.Read(childCount); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this approach, but I need guidance on where these things should go.