[llvm-dev] registering passes at the beginning/end of opt passes (new pass manager)

Juneyoung Lee via llvm-dev llvm-dev at lists.llvm.org
Fri Dec 4 00:09:40 PST 2020


Hello Min-Yih, Arthur.

Thank you for the infos.
The context was that I wanted to run a special pass at the beginning/end of
passes whenever a user is running opt with one's custom arguments.
I was curious whether there is a way to do this without using a wrapper
script that introduces the special pass's name to -passes=".." options
somehow.

It seems the register callback functions are invoked only when a default
pipeline like default<O2> is used, not when a pass
like -passes='simplify-cfg<switch-to-lookup>' is given, as Arthur described.
Since the special pass should run regardless of whether the pass is default
or not, I'll turn to manually giving the pass name and find out.

Thanks,
Juneyoung

On Fri, Dec 4, 2020 at 4:26 PM Arthur Eubanks <aeubanks at google.com> wrote:

> There are various opt options [1] that let you specify passes to add at
> specific points in the pipeline. Also, specifying a target may cause the
> corresponding TargetMachine to register pass callbacks.
> Something like "-passes=default<O2>" that creates a full pipeline will add
> those passes to the pipeline. Otherwise they aren't invoked.
>
> [1]:
> https://github.com/llvm/llvm-project/blob/f5f1a5c2448e31f3c7e6f85b378372a02f8d3e43/llvm/tools/opt/NewPMDriver.cpp#L73
>
> On Thu, Dec 3, 2020 at 8:29 PM Juneyoung Lee via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> Hello all,
>>
>> Can I register passes at the beginning/end of opt passes (new pass
>> manager)?
>>
>> I found that
>> registerPipelineStartEPCallback/registerOptimizerLastEPCallback work
>> successfully for clang, but they don't fire when opt -passes="" is used.
>>
>> Thanks,
>> Juneyoung
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>

-- 

Juneyoung Lee
Software Foundation Lab, Seoul National University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201204/6e87c6eb/attachment.html>


More information about the llvm-dev mailing list