[cfe-commits] Mark virtual members used in a deterministic order

Rafael EspĂ­ndola rafael.espindola at gmail.com
Sat Aug 25 23:29:46 PDT 2012


Currently we iterate two DenseMaps when marking virtual members used.
The problem is that the output order depends on the order they are
marked. There are some options on how to fix this

1 Define a comparison function for all functions and sort
DeferredDeclsToEmit before iterating over it.
2 Define a comparison function for at least all the virtual functions
that go in a vtable and sort that in MarkVirtualMembersReferenced.
3 Use existing deterministic iterators in  MarkVirtualMembersReferenced.
4 Add a deterministic iterator to CXXFinalOverriderMap.

fpichet on irc suggested using source code order for the comparisons,
but I am not sure that would work in cases like

class foo : public bar<int>, public bar<float>...

since the methods from bar<T> would show up twice.

I have implemented 3 by manually iterating over the methods and bases
of a class.  I am not all that happy with the result.  The method
getFinalOverriders already does a similar walk. The situation is even
worse when we need a VTT, as we call getFinalOverriders multiple times
(but that is already the case without this patch).

For option 4 we would need to replace the DenseMap in
CXXFinalOverriderMap with some ordered set container that remembers
the order in which getFinalOverriders found the members.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 4815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120826/947ba282/attachment.obj>


More information about the cfe-commits mailing list