Status of the devirtualization in LLVM/Clang

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Status of the devirtualization in LLVM/Clang

Victor Leschuk via cfe-dev
Hi folks,
I wanted to share a status on how the devirtualization is doing since I presented it on US LLVM Dev Meeting  (, short summary as a blogpost

1. Skipping the barrier:
One of the problems with the was stopping current optimizations from happening, like:
- figuring out load value through the barrier
- DSE through the barrier

After chatting with Chandler and Hal during Euro LLVM we agreed that this can be solved by giving Alias Analysis the knowledge that the pointer returned by the barrier 
mustalias it's argument. We also needed to mark the barrier with right attributes. Here are soma patches:

Accepted: - DSE through the barrier - Remove readnone from

Need review: - Handle in BasicAA - Mark as inaccessiblememonly - Simplify idempotent

I believe that this solves most (if not all) blocking optimizations problems. I even checked how many Clang's tests will fail with  -fstrict-vtable-pointers set by default, 
and all passed (there were around 15 failing before that), so I am really happy about this.

2. Hoisting loads from Loops:
I wanted to hoist vtable loads from loops, but there is a big problem with LICM: it always drops metadata. 
For loads that are guaranteed to happen it is probably safe to not discard metadata, and for speculative loads we need a new concept of metadata that holds globally (unconditionally) - like the one proposed here

3. Changes in clang: - Emit when using union field
Other things I want to work on right now is:
- emitting barriers for pointers comparison
- emitting barrier for pointer casts, when dynamic information is lost
- emitting md with empty nodes
- emitting vtable definition when all of virtual inline functions has been emitted.

Any feedback will be appreciated!


cfe-dev mailing list
[hidden email]