Skip to content

Conversation

@gbaraldi
Copy link
Contributor

@gbaraldi gbaraldi commented Sep 5, 2025

This is a very rough state of what this can look like, but I didn't want to spend too much time on what could be a dead end.

Currently the only way to invoke callbacks is by using the default pipelines, this is an issue if you want to define your own pipeline using the C string API (we do that in LLVM.jl in julia) so I extended the api to allow for invoking those callbacks just like one would call a pass of that kind.

There are some questions about the params that these callbacks take and also I'm missing some of them (some of them are also invoked by the backend so we may not want to expose them)

Code written with AI help, bugs are mine. (Not sure what policy for this is on LLVM)

@github-actions
Copy link

github-actions bot commented Sep 5, 2025

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

Copy link
Member

@mshockwave mshockwave left a comment

Choose a reason for hiding this comment

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

it'll be nice if you could also add some tests

@gbaraldi gbaraldi marked this pull request as ready for review September 16, 2025 19:48
Copy link
Contributor

@aeubanks aeubanks left a comment

Choose a reason for hiding this comment

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

this makes sense, some comments

#undef LOOP_PASS_WITH_PARAMS

#ifdef MODULE_CALLBACK
MODULE_CALLBACK("PipelineStartCallbacks", invokePipelineStartEPCallbacks)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this doesn't follow naming conventions in this file for passes, this should probably be something like callbacks-pipeline-start

return true; \
}
#include "PassRegistry.def"
#undef CGSCC_CALLBACK
Copy link
Contributor

Choose a reason for hiding this comment

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

the other macros are undefed in PassRegistry.def rather than here, why is this different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I hadn't seen that. I usually don't #define in one file and #undef in the other but following convention is fine

@gbaraldi
Copy link
Contributor Author

I don't have commit bit, so could someone commit for me :)

@mshockwave mshockwave merged commit 21f5f32 into llvm:main Sep 19, 2025
9 checks passed
@mshockwave
Copy link
Member

I don't have commit bit, so could someone commit for me :)

Done, cheers

Also I just saw:

Code written with AI help, bugs are mine. (Not sure what policy for this is on LLVM)

here is the policy: https://llvm.org/docs/DeveloperPolicy.html#ai-generated-contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants