[SCEV] Fix ValuesAtScopesUsers consistency
authorNikita Popov <npopov@redhat.com>
Fri, 3 Dec 2021 08:58:42 +0000 (09:58 +0100)
committerNikita Popov <npopov@redhat.com>
Fri, 3 Dec 2021 09:03:10 +0000 (10:03 +0100)
commit49d040ac978c60d48710d327d5d8b1bd0c9ad1fb
tree3d7186ea6c2b7f41a5cf1c794eb01f81672b7516
parent1423e8bf5dda75877c0414dd26d024fd770d71fb
[SCEV] Fix ValuesAtScopesUsers consistency

Fixes verification failure reported at:
https://reviews.llvm.org/rGc9f9be0381d1

The issue is that getSCEVAtScope() might compute a result without
inserting it in the ValuesAtScopes map in degenerate cases,
specifically if the ValuesAtScopes entry is invalidated during the
calculation. Arguably we should still insert the result if no
existing placeholder is found, but for now just tweak the logic
to only update ValuesAtScopesUsers if ValuesAtScopes is updated.
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/values-at-scopes-consistency.ll [new file with mode: 0644]