[PATCH] D144209: [ThinLTO/WPD] Handle function alias in vtable correctly

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 11:27:05 PST 2023


tejohnson created this revision.
tejohnson added reviewers: mingmingl, xur.
Herald added subscribers: ormris, jeroen.dobbelaere, steven_wu, hiraditya, inglorion, Prazek.
Herald added a project: All.
tejohnson requested review of this revision.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144209

Files:
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/ThinLTO/X86/devirt_function_alias.ll
  llvm/test/ThinLTO/X86/devirt_function_alias2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144209.498106.patch
Type: text/x-patch
Size: 9594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230216/1a2461b3/attachment.bin>


More information about the llvm-commits mailing list