Skip to content

[ctx_profile] Pull ContextNode in a .h file #91669

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

Merged
merged 5 commits into from
May 9, 2024
Merged

Conversation

mtrofin
Copy link
Member

@mtrofin mtrofin commented May 9, 2024

This pulls out ContextNode as we need to use it pretty much as-is to implement a writer. The writer will be implemented on the LLVM side because it takes a dependency on BitStreamWriter.

Since we can't reuse a header between compiler-rt and llvm, we use a .inc which is copied on both sides, and test that the 2 copies are identical.

The changes adds the necessary other stuff for compiler-rt/ctx_profile testing.

This pulls out `ContextNode` as we need to use it pretty much as-is to
implement a writer. The writer will be implemented on the LLVM side because
it takes a dependency on BitStreamWriter.

Since we can't reuse a header between compiler-rt and llvm, we use a .inc
which is copied on both sides, and test that the 2 copies are identical.

The changes adds the necessary other stuff for compiler-rt/ctx_profile testing.
@mtrofin mtrofin requested a review from snehasish May 9, 2024 22:09
Copy link

github-actions bot commented May 9, 2024

✅ With the latest revision this PR passed the Python code formatter.

// NOTE!
// llvm/lib/ProfileData/CtxInstrContextNode.inc and
// compiler-rt/lib/ctx_profile/CtxInstrContextNode.inc
// must be exact copies of eachother
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space between each and other?

/// to be concerned with memory safety. Their subcontexts never get populated,
/// though. The runtime code here produces and recognizes them.

using GUID = uint64_t;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a couple of things here:

  1. An include guard to make sure things don't get pulled in twice.
  2. Depending on where these things are pulled in from, they may end up with different namespaces. Usually we define the namespaces we want these to be in at this location.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that really says "this should be a header", which this isn't at the moment. There's some - but not lots - of advantage to that, but there is one challenge: what's the include guard going to be - because it won't be matching the guideline on the llvm side.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind - made it a header. What was giving me pause is 2 things: one, what exactly should the include guard be, because there's a guideline about naming it that captures its path. Looks like compiler-rt doesn't really have that, so using LLVM as SoT. Second, standard includes. But the 2 I need are also on the compiler-rt, and since the goal of this type is to stay fairly low-level, it's probably fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice, is it possible to have this config shared across other compiler-rt projects?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdym - the other test dirs have a thing like this

Copy link

github-actions bot commented May 9, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@snehasish snehasish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mtrofin mtrofin merged commit e4763ca into llvm:main May 9, 2024
@mtrofin mtrofin changed the title [ctx_profile] Pull ContextNode in a .inc file [ctx_profile] Pull ContextNode in a .h file May 9, 2024
mtrofin added a commit that referenced this pull request May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants