[PATCH] Some minor update in PassManager.h

Dinesh Dwivedi dinesh.d at samsung.com
Wed Apr 8 14:53:25 PDT 2015


Sorry if does not make any sense but following is my analysis on why we can't use 
perfect forwarding here with the trick.

Conclusion:
We can use perfect forwarding for an argument with my trick only of given method (run)
takes that argument by reference.

Explanation:
Reference collapsing always return a reference, for a l-value or l-value reference to a 
function template taking universal reference, it will treat it as l-value reference and for 
r-value reference, as r-value reference. So type of invokeWithOptionalArgs's last 2 
arguments, if we use perfect forwarding, will always be deduced as reference to some type.

In invokeWithOptionalArgs, we are trying to check if passed class (C) has given method 
(f) or not, which deduce A1, A2 etc as parameter type of C:;f. If it does not match with 
the deduced type for A1 and A2 from last 2 parameters (IR and AM) then that version 
of invokeWithOptionalArgs will be removed from overload resolution (SFINAE).

In the case here, Run method takes AnalysisManager as pointer but if we use perfect 
forwarding, A2 gets deduced as (dues to last argument passed to invokeWithOptionalArgs 
(AM)) reference to AnalysisManager pointer (SFINAE case)

For A1, perfect forwarding works fine as all pass takes IR as reference.


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D3543

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list