[PATCH] D89587: [CGSCC] Detect devirtualization in more cases

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 12:56:36 PDT 2020


aeubanks created this revision.
aeubanks added reviewers: ychen, asbirlea, rnk.
Herald added subscribers: llvm-commits, hiraditya, Prazek.
Herald added a project: LLVM.
aeubanks requested review of this revision.

The devirtualization wrapper misses cases where if it wraps a pass
manager, an individual pass may devirtualize an indirect call created by
a previous pass. For example, inlining may create a new indirect call
which is devirtualized by instcombine. Currently the devirtualization
wrapper will not see that because it only checks cgscc edges at the very
beginning and end of the pass (manager) it wraps.

This fixes some tests testing this exact behavior in the legacy PM.

This piggybacks off of updateCGAndAnalysisManagerForPass()'s detection
of promoted ref to call edges.

This supercedes one of the previous mechanisms to detect
devirtualization by keeping track of potentially promoted call
instructions via WeakTrackingVHs.

There is one more existing way of detecting devirtualization, by
checking if the number of indirect calls has decreased and the number of
direct calls has increased in a function. It handles cases where calls
to functions without definitions are promoted, and some tests rely on
that. LazyCallGraph doesn't track edges to functions without
definitions so this part can't be removed in this change.

check-llvm and check-clang with -abort-on-max-devirt-iterations-reached
on by default doesn't show any failures outside of tests specifically
testing it so it doesn't needlessly rerun passes more than necessary.
(The NPM -O2/3 pipeline run the inliner/function simplification pipeline
under a devirtualization repeater pass up to 4 times by default).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89587

Files:
  llvm/include/llvm/Analysis/CGSCCPassManager.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/test/Transforms/Inline/devirtualize-3.ll
  llvm/test/Transforms/Inline/devirtualize-5.ll
  llvm/test/Transforms/Inline/devirtualize.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89587.298729.patch
Type: text/x-patch
Size: 6240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201016/91c53748/attachment.bin>


More information about the llvm-commits mailing list