[PATCH] D17259: [PM/AA] Teach the new pass manager to use pass-by-lambda for registering analysis passes, support pre-registering analyses, and use that to implement parsing and pre-registering a custom alias analysis pipeline.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 20:01:22 PST 2016


Thanks for the explanation. Looks like I should mostly have read it better the first time, but I'm more or less up to speed now.

If you wanted a LGTM from me too then you have it. Wasn't sure if you wanted an ok or not after Philip's LGTM :)

Cheers
Pete

Sent from my iPhone

> On Feb 15, 2016, at 3:00 PM, Chandler Carruth <chandlerc at gmail.com> wrote:
> 
> chandlerc added a comment.
> 
> In http://reviews.llvm.org/D17259#352996, @pete wrote:
> 
>> So i'm not against the lambda's if they are required, but I can't really see why we need them instead of say, a function pointer?
>> 
>> Eg, instead of
>> 
>>  MAM.registerPass([&] { return FunctionAnalysisManagerModuleProxy(FAM); });
>> 
>> 
>> do
>> 
>>  MAM.registerPass(&FunctionAnalysisManagerModuleProxy)
> 
> 
> This doesn't compile because that isn't a function. It is a constructor that builds a temporary.
> 
> The routine however *would* be fine with a function pointer if we had such a thing. The routine is being generic and accepting any callable. Callers can use a function pointer or a lambda or whatever else. A lambda has the nice property of being a maximally generic way to pass in a lazy-evaluated expression.
> 
>> Also, looks like the lambda (or function pointer), is being used to make sure we don't construct a pass twice.  Why not jus make that an error to register the same pass twice?  Is that something we can say is a condition of using the new pass manager?
> 
> 
> Well, the previous code did exactly that. ;] The patch description (i thought) explained why I am changing it: we need some way to explicitly handle the AAManager's registration outside of the generic registerFunctionAnalyses routine. The best idea I had for an interface was to pre-register the analyses which require custom logic, and then register the remaining ones with the generic logic in PassBuilder::register*Analyses.
> 
> The code to use this facility is also included in the patch. See the code in NewPMDriver.cpp where we call registerFunctionAnalyses. If you add back the assert that this patch removes from registerPass, it will fire because we will register AAManager twice.
> 
> 
> http://reviews.llvm.org/D17259
> 
> 
> 


More information about the llvm-commits mailing list