This is an archive of the discontinued LLVM Phabricator instance.

[IndVars] Option verify-indvars is broken (and always has been), delete it
ClosedPublic

Authored by mkazantsev on Mar 12 2023, 9:49 PM.

Details

Summary

This option is switched off by default, and it seems that it has never worked correctly.
What it basically does is: it remembers current BECount SCEV, and after all transforms
tries to validate some facts for it. However, between these two points this SCEV may
become invalid (e.g. because some SCEVUnknown it references may be deleted as dead
code). So basically it may work with broken pointers.

Besides, its implementation does strange things (e.g. forgetLoop) which are invasive and
may affect behavior in other parts of the system (specifically verification), concealing some
other problems. Another issue is that it may use SCEVCouldNotCompute object without
checking this.

The option is not used in any unit tests, and if switched on by default, the following tests
fail:

********************
Failed Tests (14):
  LLVM :: Transforms/IndVarSimplify/2005-06-15-InstMoveCrash.ll
  LLVM :: Transforms/IndVarSimplify/2007-06-06-DeleteDanglesPtr.ll
  LLVM :: Transforms/IndVarSimplify/2008-10-03-CouldNotCompute.ll
  LLVM :: Transforms/IndVarSimplify/2009-05-24-useafterfree.ll
  LLVM :: Transforms/IndVarSimplify/2011-10-27-lftrnull.ll
  LLVM :: Transforms/IndVarSimplify/ARM/code-size.ll
  LLVM :: Transforms/IndVarSimplify/X86/deterministic-scev-verify.ll
  LLVM :: Transforms/IndVarSimplify/X86/pr57187.ll
  LLVM :: Transforms/IndVarSimplify/X86/verify-scev.ll
  LLVM :: Transforms/IndVarSimplify/bbi-63564.ll
  LLVM :: Transforms/IndVarSimplify/invalidate-modified-lcssa-phi.ll
  LLVM :: Transforms/IndVarSimplify/loop-predication.ll
  LLVM :: Transforms/IndVarSimplify/post-inc-range.ll
  LLVM :: Transforms/IndVarSimplify/turn-to-invariant.ll

********************
Unexpectedly Passed Tests (1):
  LLVM :: Transforms/IndVarSimplify/pr55689.ll

None of these looks like real problems found by verification, these are
bugs in the verifying code itself (such as use of deleted SCEVs and
SCEVCouldNotCompute's).

I think it all gives enough justification for its removal.

Diff Detail

Event Timeline

mkazantsev created this revision.Mar 12 2023, 9:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2023, 9:49 PM
mkazantsev requested review of this revision.Mar 12 2023, 9:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2023, 9:49 PM
mkazantsev edited the summary of this revision. (Show Details)Mar 12 2023, 9:50 PM
foad added a subscriber: foad.Mar 12 2023, 11:51 PM
nikic requested changes to this revision.Mar 13 2023, 1:10 AM
nikic added inline comments.
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
2203

Accidentally also dropped MSSA verification?

This revision now requires changes to proceed.Mar 13 2023, 1:10 AM
mkazantsev added inline comments.Mar 13 2023, 7:24 AM
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
2203

Yeah, thanks for pointing out.

mkazantsev marked an inline comment as done.
nikic accepted this revision.Mar 14 2023, 1:37 AM

LGTM

llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
2162

You can drop the ifndef -- we generally don't place VerifyMemorySSA behind NDEBUG, because you need to enable it via a flag anyway.

This revision is now accepted and ready to land.Mar 14 2023, 1:37 AM