[LLVMdev] Implementing devirtualization
Chris Lattner
clattner at apple.com
Mon Dec 12 23:43:07 PST 2011
On Dec 12, 2011, at 6:16 PM, Nick Lewycky wrote:
>> Language guarantees are *really, really useful*. I understand the desire to improve optimizations that don't require language-specific annotations, but I am not sure it is very practical.
>
> I don't disagree at all. I really do want to optimize based on the
> program's behaviour as much as possible, falling back on additional
> language-provided guarantees only when necessary.
I think that this is a great general approach, particularly given that devirt is just a special case of other very common patterns (e.g. default constructors usually initialize all fields). This could be implemented with relatively straight-forward improvements to our AA/memdep infrastructure to allow it to forward values from calls to loads.
The only thing I'm worried about is how expensive the analysis for this would be. This could be handled with some simple summary functions stuff along the lines of global mod/ref (with a threshold to bail out in insane cases).
Once the general infrastructure exists, we could add intrinsics or something else for languages that know stuff to communicate it to the optimizer.
-Chris
More information about the llvm-dev
mailing list