[llvm] r218004 - Add a new pass FunctionTargetTransformInfo. This pass serves as a

Eric Christopher echristo at gmail.com
Wed Sep 17 23:53:31 PDT 2014


>
>> -void PPCTTI::getUnrollingPreferences(Loop *L, UnrollingPreferences &UP)
>>>> const {
>>>> -  if (ST->getDarwinDirective() == PPC::DIR_A2) {
>>>> +void PPCTTI::getUnrollingPreferences(const Function *F, Loop *L,
>>>> +                                     UnrollingPreferences &UP) const {
>>>>
>>>
>>> And in places like this, if you passed the Subtarget, you could even
>>> call it "ST" and then the body of the function wouldn't need any changes at
>>> all. (granted, shadowing is subtle stuff... so I can understand if that's
>>> not ideal - but given the ultimate future will end up removing the member
>>> variable, it might be an acceptable intermediate state to reduce
>>> typing/churn)
>>>
>>
>> Right. And this would be why it might work. I.e. instead of Function,
>> take Subtarget since that'll be what everything uses ultimately to get the
>> various target data structures. I have no ultimate preference here other
>> than I will likely have to cast that subtarget no matter what to be the
>> type of the actual TargetSubtargetInfo that the target wants (I.e.
>> PPCSubtargetInfo).
>>
>> That said, it doesn't necessarily lose me anything.
>>
>
> Having thought about this I think I'm going to go with it. I'll still have
> to do the specific casts but it will save some additional lookups and
> compile time. It might be premature optimization, but the API isn't any
> worse with it so let's do it.
>
>
Well, it turns out you can't get there from here. At least not by any map
I've got.

The function doesn't have a pointer to the TargetMachine which means I
can't do it via runOnFunction, so the only way I could construct this would
be to use INITIALIZE_TM_PASS, but that will end up putting CodeGen into
Analysis, which puts it into Scalar opts, which the comment above
INITIALIZE_TM_PASS says would cause a cycle and don't do it.

I might be able to add a getAnalysis that takes a TM as an argument, but
that starts to lead us down the same hole.

cc'ing Chandler to see if he has any ideas.

-eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140917/8018db35/attachment.html>


More information about the llvm-commits mailing list