[llvm-dev] How to get analysis in a class which is not a LLVM pass?

vivek pandya via llvm-dev llvm-dev at lists.llvm.org
Wed Jul 13 21:02:27 PDT 2016


On Thu, Jul 14, 2016 at 2:27 AM, Mehdi Amini <mehdi.amini at apple.com> wrote:

>
> > On Jul 13, 2016, at 1:06 PM, Quentin Colombet via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
> >
> > Hi,
> >
> >> On Jul 13, 2016, at 1:03 AM, vivek pandya via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
> >>
> >> Hello,
> >>
> >> I want to use ProfileSummaryInfo in a class which is not a LLVM pass
> like TargetFrameLowering class (lib/CodeGen/TargetFrameLoweringImpl.cpp)
> >>
> >> one way I know to get ProfileSummaryInfo is
> >> getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI(M);
> >> but I can't use this.
> >>
> >> Is this really possible?
> >
> > Not really. That would mean that anything that uses the method that
> access that information would need to depend on
> ProfileSummaryInfoWrapperPass, which is pretty bad from the software
> engineering standpoint.
> >
> > Something possible is to use getAnalysisIfAvailable (or something like
> that, I haven’t checked the actual name), but that means you need to be
> able to work correctly if the pass is not available.
>
> It is more complex than that: if the class where you need it is not a Pass
> itself (as Vivek mentions above), you can’t call getAnalysisIfAvailable
> either.
>
> I believe the right way to do it is to extend the API to take an optional
> (or mandatory depending on what is done) extra object. Here it could be
> ProfileSummaryInfo for instance, but maybe something more targeted like a
> bool if all what’s needed is to answer “Am I processing a hot or cold
> function?”.
>
I do not understand this clearly. Do you here mean to extern MF API or
determineCalleeSaves() in TargetFrameLowering. I wanted to do all
processing inside TargetFrameLoweringImpl so that optimization will be
target independent. Other wise if we plan to pass ProfileSummaryInfo from
X86TargetFrameLowering (which it self is not pass) or some pass which is
using it than it would become target dependent.

-Vivek

>
>> Mehdi
>
>
>
>
> >
> > Cheers,
> > Q.
> >
> >>
> >> Sincerely,
> >> Vivek
> >> _______________________________________________
> >> LLVM Developers mailing list
> >> llvm-dev at lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160714/e5792779/attachment.html>


More information about the llvm-dev mailing list