vivek pandya via llvm-dev
2016-Jul-13 08:03 UTC
[llvm-dev] How to get analysis in a class which is not a LLVM pass?
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? Sincerely, Vivek -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160713/3ccc1802/attachment.html>
Quentin Colombet via llvm-dev
2016-Jul-13 20:06 UTC
[llvm-dev] How to get analysis in a class which is not a LLVM pass?
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. Cheers, Q.> > Sincerely, > Vivek > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Mehdi Amini via llvm-dev
2016-Jul-13 20:57 UTC
[llvm-dev] How to get analysis in a class which is not a LLVM pass?
> 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?”. — 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
Apparently Analagous Threads
- Suggestion / Help regarding new calling convention
- Suggestion / Help regarding new calling convention
- Tail call optimization is getting affected due to local function related optimization with IPRA
- Segfault in llc 3.8.0 building GHC
- [ThinLTO] Importing based on PGO data