Skip to content

Commit 8ce1011

Browse files
committed
Adapt to reviewer comments.
1 parent 46de6fb commit 8ce1011

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

llvm/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ Changes to the C API
157157
* ``LLVMGetNamedFunctionWithLength``
158158
* ``LLVMGetNamedGlobalWithLength``
159159

160+
* The new pass manager can now be invoked with a custom alias analysis pipeline, using
161+
the ``LLVMPassBuilderOptionsSetAAPipeline`` function.
162+
163+
* It is now also possible to run the new pass manager on a single function, by calling
164+
``LLVMRunPassesOnFunction`` instead of ``LLVMRunPasses``.
165+
160166
Changes to the CodeGen infrastructure
161167
-------------------------------------
162168

llvm/include/llvm-c/Transforms/PassBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes,
5151
LLVMPassBuilderOptionsRef Options);
5252

5353
/**
54-
* Construct and run a set of passes over a function
54+
* Construct and run a set of passes over a function.
5555
*
5656
* This function behaves the same as LLVMRunPasses, but operates on a single
5757
* function instead of an entire module.

llvm/lib/Passes/PassBuilderBindings.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,12 @@ static TargetMachine *unwrap(LLVMTargetMachineRef P) {
4848
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMPassBuilderOptions,
4949
LLVMPassBuilderOptionsRef)
5050

51-
LLVMErrorRef RunPasses(LLVMModuleRef M, LLVMValueRef F, const char *Passes,
52-
LLVMTargetMachineRef TM,
53-
LLVMPassBuilderOptionsRef Options) {
54-
TargetMachine *Machine = unwrap(TM);
55-
LLVMPassBuilderOptions *PassOpts = unwrap(Options);
51+
static LLVMErrorRef runPasses(Module *Mod, Function *Fun, const char *Passes,
52+
TargetMachine *Machine,
53+
LLVMPassBuilderOptions *PassOpts) {
5654
bool Debug = PassOpts->DebugLogging;
5755
bool VerifyEach = PassOpts->VerifyEach;
5856

59-
// Determine what to run passes on.
60-
Module *Mod;
61-
Function *Fun = nullptr;
62-
if (F) {
63-
Fun = unwrap<Function>(F);
64-
Mod = Fun->getParent();
65-
} else {
66-
Mod = unwrap(M);
67-
}
68-
6957
PassInstrumentationCallbacks PIC;
7058
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC);
7159

@@ -113,13 +101,19 @@ LLVMErrorRef RunPasses(LLVMModuleRef M, LLVMValueRef F, const char *Passes,
113101
LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes,
114102
LLVMTargetMachineRef TM,
115103
LLVMPassBuilderOptionsRef Options) {
116-
return RunPasses(M, nullptr, Passes, TM, Options);
104+
TargetMachine *Machine = unwrap(TM);
105+
LLVMPassBuilderOptions *PassOpts = unwrap(Options);
106+
Module *Mod = unwrap(M);
107+
return runPasses(Mod, nullptr, Passes, Machine, PassOpts);
117108
}
118109

119110
LLVMErrorRef LLVMRunPassesOnFunction(LLVMValueRef F, const char *Passes,
120111
LLVMTargetMachineRef TM,
121112
LLVMPassBuilderOptionsRef Options) {
122-
return RunPasses(nullptr, F, Passes, TM, Options);
113+
TargetMachine *Machine = unwrap(TM);
114+
LLVMPassBuilderOptions *PassOpts = unwrap(Options);
115+
Function *Fun = unwrap<Function>(F);
116+
return runPasses(Fun->getParent(), Fun, Passes, Machine, PassOpts);
123117
}
124118

125119
LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions() {

0 commit comments

Comments
 (0)