[all-commits] [llvm/llvm-project] 985b9b: [PM] Avoid duplicates in the Used/Preserved/Requir...

Björn Pettersson via All-commits all-commits at lists.llvm.org
Wed Jan 20 04:56:49 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 985b9b7e421a16e8fcab7f038601a23a25cdfd5d
      https://github.com/llvm/llvm-project/commit/985b9b7e421a16e8fcab7f038601a23a25cdfd5d
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2021-01-20 (Wed, 20 Jan 2021)

  Changed paths:
    M llvm/include/llvm/PassAnalysisSupport.h
    M llvm/lib/IR/LegacyPassManager.cpp
    M llvm/lib/IR/Pass.cpp

  Log Message:
  -----------
  [PM] Avoid duplicates in the Used/Preserved/Required sets

The pass analysis uses "sets" implemented using a SmallVector type
to keep track of Used, Preserved, Required and RequiredTransitive
passes. When having nested analyses we could end up with duplicates
in those sets, as there was no checks to see if a pass already
existed in the "set" before pushing to the vectors. This idea with
this patch is to avoid such duplicates by avoiding pushing elements
that already is contained when adding elements to those sets.

To align with the above PMDataManager::collectRequiredAndUsedAnalyses
is changed to skip adding both the Required and RequiredTransitive
passes to its result vectors (since RequiredTransitive always is
a subset of Required we ended up with duplicates when traversing
both sets).

Main goal with this is to avoid spending time verifying the same
analysis mulitple times in PMDataManager::verifyPreservedAnalysis
when iterating over the Preserved "set". It is assumed that removing
duplicates from a "set" shouldn't have any other negative impact
(I have not seen any problems so far). If this ends up causing
problems one could do some uniqueness filtering of the vector being
traversed in verifyPreservedAnalysis instead.

Reviewed By: foad

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




More information about the All-commits mailing list