Commit 6e530a3d authored by Jeroen Dobbelaere's avatar Jeroen Dobbelaere
Browse files

[Verifier] enable and limit llvm.experimental.noalias.scope.decl dominance checking

Checking the llvm.experimental.noalias.scope.decl dominance can be worstcase O(N^2).
Limit the dominance check to N=32.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D95335
parent 7e506b30
Loading
Loading
Loading
Loading
+12 −13
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@
using namespace llvm;

static cl::opt<bool> VerifyNoAliasScopeDomination(
    "verify-noalias-scope-decl-dom", cl::Hidden, cl::init(false),
    "verify-noalias-scope-decl-dom", cl::Hidden, cl::init(true),
    cl::desc("Ensure that llvm.experimental.noalias.scope.decl for identical "
             "scopes are not dominating"));

@@ -5587,18 +5587,17 @@ void Verifier::verifyNoAliasScopeDecl() {
    } while (ItNext != NoAliasScopeDecls.end() &&
             GetScope(*ItNext) == CurScope);

    // [ItCurrent, ItNext[ represents the declarations for the same scope.
    // Ensure they are not dominating each other
    for (auto *I : llvm::make_range(ItCurrent, ItNext)) {
      for (auto *J : llvm::make_range(ItCurrent, ItNext)) {
        if (I != J) {
    // [ItCurrent, ItNext) represents the declarations for the same scope.
    // Ensure they are not dominating each other.. but only if it is not too
    // expensive.
    if (ItNext - ItCurrent < 32)
      for (auto *I : llvm::make_range(ItCurrent, ItNext))
        for (auto *J : llvm::make_range(ItCurrent, ItNext))
          if (I != J)
            Assert(!DT.dominates(I, J),
                   "llvm.experimental.noalias.scope.decl dominates another one "
                   "with the same scope",
                   I);
        }
      }
    }
    ItCurrent = ItNext;
  }
}