[all-commits] [llvm/llvm-project] cba3e7: [NewPM] Disable PreservedCFGChecker and add regres...

Yevgeny Rouban via All-commits all-commits at lists.llvm.org
Tue Nov 17 19:04:10 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: cba3e783389a6319927b4755d3fb22e2464b30a1
      https://github.com/llvm/llvm-project/commit/cba3e783389a6319927b4755d3fb22e2464b30a1
  Author: Yevgeny Rouban <yrouban at azul.com>
  Date:   2020-11-18 (Wed, 18 Nov 2020)

  Changed paths:
    M llvm/lib/Passes/StandardInstrumentations.cpp
    M llvm/unittests/IR/PassManagerTest.cpp

  Log Message:
  -----------
  [NewPM] Disable PreservedCFGChecker and add regression unit tests

The design of the PreservedCFG Checker (landed with the commit
28012e00d80b9) has a fundamental flaw which makes it incorrect.
The checker is based on the PreservedAnalyses result returned
by functional passes: if CFGAnalyses is in the returned
PreservedAnalyses set, then the checker asserts that the CFG
snapshot saved before the pass is equal to the CFG snapshot
taken after the the pass. The problem is in passes that change
CFG and invalidate CFGAnalyses on their own. Such passes do not
return CFGanalyses in the returned PreservedAnalyses. So the
checker mistakenly expects CFG unchanged. As an example see the
class TestSimplifyCFGInvalidatingAnalysisPass in the new tests.

It is interesting that the bug was not found in LLVM. That is
because the CFG checker ran only if CFGAnalyses was checked
incorrectly:
  if (!PassPA.allAnalysesInSetPreserved<CFGAnalyses>())
    return;

but must be checked as follows:
  auto PAC = PA.getChecker<PreservedCFGCheckerAnalysis>();
  if (!(PAC.preserved() ||
        PAC.preservedSet<AllAnalysesOn<Function>>() ||
        PAC.preservedSet<CFGAnalyses>())
    return;

A fully redesigned checker will be sent as a separate follow-up
patch.

Reviewed By: Serguei Katkov, Jakub Kuderski

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




More information about the All-commits mailing list