This is an archive of the discontinued LLVM Phabricator instance.

WholeProgramDevirt: Change internal vcall data structures to match summary.
ClosedPublic

Authored by pcc on Feb 8 2017, 6:42 PM.

Details

Summary

Group calls into constant and non-constant arguments up front, and use uint64_t
instead of ConstantInt to represent constant arguments. The goal is to allow
the information from the summary to fit naturally into this data structure in
a future change (specifically, it will be added to CallSiteInfo).

This has two side effects:

  • We disallow VCP for constant integer arguments of width >64 bits.
  • We remove the restriction that the bitwidth of a vcall's argument and return types must match those of the vfunc definitions.

I don't expect either of these to matter in practice. The first case is
uncommon, and the second one will lead to UB (so we can do anything we like).

Event Timeline

pcc created this revision.Feb 8 2017, 6:42 PM
pcc updated this revision to Diff 87752.Feb 8 2017, 7:13 PM
  • Small tweak to make my next change NFC
tejohnson added inline comments.Feb 14 2017, 8:50 AM
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
285

Document the new structures

291

Please document what this map is holding (vs the single CSInfo above). I believe I deduced it from code below, but better to document so one doesn't need to see how these are accessed to understand.

667

Why are the ZExt here and in below function now required?

llvm/test/Transforms/WholeProgramDevirt/vcp-too-wide-ints.ll
12

Why are these changes useful/necessary? Is there less coverage with the return type being dropped to i64?

llvm/test/Transforms/WholeProgramDevirt/vcp-type-mismatch.ll
34

Comment about why we can do optimization (function name still just says "bad_arg_type", which implies not being able to do it).

64

ditto

pcc updated this revision to Diff 88426.Feb 14 2017, 1:23 PM
pcc marked 4 inline comments as done.
  • Address review comments
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
667

This one is needed because there is now the possibility of a mismatch between the return type of the function and the type of Cmp (always i1 before). I've added a test showing that we handle that case.

The one in tryVirtualConstProp is unnecessary, I've removed it.

llvm/test/Transforms/WholeProgramDevirt/vcp-too-wide-ints.ll
12

This change was to cover specifically the rejection due to the wide argument type. Good catch for the return type, I've re-added coverage for that.

llvm/test/Transforms/WholeProgramDevirt/vcp-type-mismatch.ll
34

Added a comment to the top of the file.

pcc updated this revision to Diff 88428.Feb 14 2017, 1:32 PM
  • Revert an irrelevant change
pcc updated this revision to Diff 88432.Feb 14 2017, 1:59 PM
  • Revert "Revert an irrelevant change", this was needed after all
This revision is now accepted and ready to land.Feb 14 2017, 2:08 PM
This revision was automatically updated to reflect the committed changes.