[all-commits] [llvm/llvm-project] 8045ba: [ThinLTO/WPD] Handle function alias in vtable corr...

Teresa Johnson via All-commits all-commits at lists.llvm.org
Thu Feb 16 18:20:35 PST 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8045ba89488c9f7cc1c291e6c939e02e04fbcd2e
  Author: Teresa Johnson <tejohnson at google.com>
  Date:   2023-02-16 (Thu, 16 Feb 2023)

  Changed paths:
    M llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
    M llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
    A llvm/test/ThinLTO/X86/devirt_function_alias.ll
    A llvm/test/ThinLTO/X86/devirt_function_alias2.ll

  Log Message:
  [ThinLTO/WPD] Handle function alias in vtable correctly

We were not summarizing a function alias in the vtable, leading to
incorrect WPD in some cases, and missing WPD in others.

Specifically, we would end up ignoring function aliases as they aren't
summarized, so we could incorrectly devirtualize if there was a single
other non-alias function in a compatible vtable. And if there was only
one implementation, but it was an alias, we would not be able to
identify and perform the single implementation devirtualization.

Handling the alias summary correctly also required fixing the handling
in mustBeUnreachableFunction, so that it is not incorrectly ignored.

Regular LTO is conservatively correct because it will skip
devirtualizing when any pointer within a vtable is not a function.
However, it needs additional work to be able to take advantage of
function alias within the vtable that is in fact the only
implementation. For that reason, the Regular LTO testing in the second
test case is currently disabled, and will be enabled along with a follow
on enhancement fix for Regular LTO WPD.

Differential Revision: https://reviews.llvm.org/D144209

More information about the All-commits mailing list