[PATCH] Store reference to corresponding PassInfo in Pass

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Jan 14 14:31:08 PST 2014


ccing Chandler who is rewriting the pass manager at the moment.

On 29 December 2013 09:06, Carl-Anton Ingmarsson
<ca.ingmarsson at gmail.com> wrote:
> When profiling the rust compiler I noticed that it spends a lot of time
> in llvm::PassRegistry::getPassInfo(). Although
> llvm::PassRegistry::getPassInfo() is reasonably simple it involves a
> lock and a hash table lookup which by no means is free.
>
> Since a Pass is closely associated with it's PassInfo I think it makes
> sense to keep a reference to the PassInfo from the Pass and then add a
> Pass::getPassInfo() function that users can use to get the PassInfo from
> a Pass object.
>
> I first tried to lookup and store the PassInfo reference in the Pass
> constructor but this unfortunately didn't work since some Pass
> implementations doesn't register it's corresponding PassInfo until the
> first Pass is constructed. This could be fixed by changing the Pass
> constructor to take the PassInfo and then subclasses could pass the
> result of it's "initialize***Pass" to the parent constructor. Since this
> involves changing all the Pass implementations I decided to do a simpler
> version for now and hear your opinions.
>
> I've attached the simple (hacky) version that simply calls
> llvm::PassRegistry::getPassInfo() inside llvm::Pass::getPassInfo() if
> the PassInfo hasn't previously been fetched.
>
> In my test this reduces the percentage of time spent in
> llvm::PassRegistry::getPassInfo() from 6.21% to 0.03%. (The new
> llvm::Pass::getPassInfo() doesn't show up in the profile at all)
>
> Best regards,
> Carl-Anton
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



More information about the llvm-commits mailing list