RFC for porting VFE to thinLTO

Virtual Function Elimination (VFE) currently works with monoLTO. Given that a lot of apps are using thinLTO, we can port VFE to thinLTO by adding contents to SummaryIndex and passing the SummaryIndex to GlobalDCE where the elimination happens.

With monoLTO, GlobalDCE starts with live globals, and adds referenced globals to the live set. When VFE is enabled, references from vtable are replaced based on intrinsics and metadata.

With thinLTO, we can’t track the global live set, but we can try to eliminate virtual functions under the following conditions:

  1. There are no references to the virtual functions other than from the vtable
  2. The virtual functions are not used by analyzing the global summary which includes information for intrinsics and metadata that is used by Whole Program Devirt (WPD) and VFE
  3. The function is not in the preserved symbol list

Summaries already exist for WPD with thinLTO, we can add additional summaries as needed. Currently VFE only looks at llvm.type.checked.load intrinsics and WPD will modify the intrinsics and vcall visibility. So one option is to add a run of GlobalDCE prior to WPD for thinLTO.

General feedback on this is appreciated. If this sounds okay, patches will follow.

CC @teresajohnson @kubamracek @kyulee-com @NuriAmari @lanza