[llvm] r225750 - [PM] Fix another place where I was using an overly generic T&& for the

Chandler Carruth chandlerc at gmail.com
Tue Jan 13 01:42:57 PST 2015


On Mon, Jan 12, 2015 at 8:02 PM, David Blaikie <dblaikie at gmail.com> wrote:

> On Mon, Jan 12, 2015 at 5:44 PM, Chandler Carruth <chandlerc at gmail.com>
> wrote:
>
>> Author: chandlerc
>> Date: Mon Jan 12 19:44:56 2015
>> New Revision: 225750
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=225750&view=rev
>> Log:
>> [PM] Fix another place where I was using an overly generic T&& for the
>> IR unit to directly use IRUnitT& for now.
>>
>> Modified:
>>     llvm/trunk/include/llvm/IR/PassManager.h
>>
>> Modified: llvm/trunk/include/llvm/IR/PassManager.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/PassManager.h?rev=225750&r1=225749&r2=225750&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/IR/PassManager.h (original)
>> +++ llvm/trunk/include/llvm/IR/PassManager.h Mon Jan 12 19:44:56 2015
>> @@ -828,7 +828,7 @@ template <typename AnalysisT> struct Inv
>>  /// analysis passes to be re-run to produce fresh results if any are
>> needed.
>>  struct InvalidateAllAnalysesPass {
>>    /// \brief Run this pass over some unit of IR.
>> -  template <typename T> PreservedAnalyses run(T &&Arg) {
>> +  template <typename IRUnitT> PreservedAnalyses run(IRUnitT &Arg) {
>>
>
> Since this isn't a virtual function you're implementing, you could add
> 'const' here without breaking any contracts (it's compatible with callers
> passing non-const, but helps (only slightly) indicate that this isn't
> modifying.
>

I would much prefer that this remain consistent with the signature of every
other analysis.


>
> Arguably, I would imagine, all Analyses should take a const ref to the
> IRUnit?
>

Arguably. However, IR isn't terribly const-correct currently. The most
egregious example of this that jumps to mind is that you can't create a
ValueHandle around a const Value. I think this is an API bug as doing this
doesn't change the observable properties of the Value, but I'm not really
prepared to fix *all* of the non-const APIs that have evolved as a
consequence of that API bug. =/ At some point, it would be nice to try to
work bottom up and const-correct the API so that const served as a useful
guard for what an analysis should and shouldn't be doing to the IR it
accesses, it's just a *lot* of work and the pass manager stuff is enough as
it stands. At least, that's currently where I've come down on the APIs. =/
Not at all ideal though.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150113/4458a1a9/attachment.html>


More information about the llvm-commits mailing list