[llvm] [LLVM][NewPM] Add C API for running the pipeline on a single function. (PR #103773)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 00:26:04 PDT 2024
================
@@ -48,15 +48,24 @@ static TargetMachine *unwrap(LLVMTargetMachineRef P) {
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMPassBuilderOptions,
LLVMPassBuilderOptionsRef)
-LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes,
- LLVMTargetMachineRef TM,
- LLVMPassBuilderOptionsRef Options) {
+LLVMErrorRef RunPasses(LLVMModuleRef M, LLVMValueRef F, const char *Passes,
+ LLVMTargetMachineRef TM,
+ LLVMPassBuilderOptionsRef Options) {
TargetMachine *Machine = unwrap(TM);
LLVMPassBuilderOptions *PassOpts = unwrap(Options);
bool Debug = PassOpts->DebugLogging;
bool VerifyEach = PassOpts->VerifyEach;
- Module *Mod = unwrap(M);
+ // Determine what to run passes on.
+ Module *Mod;
+ Function *Fun = nullptr;
+ if (F) {
+ Fun = unwrap<Function>(F);
+ Mod = Fun->getParent();
+ } else {
+ Mod = unwrap(M);
+ }
----------------
nikic wrote:
I think this code should go into the caller.
https://github.com/llvm/llvm-project/pull/103773
More information about the llvm-commits
mailing list