Checking the llvm.experimental.noalias.scope.decl dominance can be worstcase O(N^2).
Limit the dominance check to N=32.
Details
Diff Detail
Event Timeline
For what it's worth, the number '1000' comes from experiments triggering the worst case behavior. With 1000 basic blocks and scope declarations, the time for parsing and checking on my testmachine was roughly 0.1 seconds. (Going to approx 1 second for 4000 blocks and declarations).
For a stage2 release build and the test-suite, the largest amount of noalias scope decls for a function is 1075 (triggered by llvm/unittests/ADT/SmallVectorTest.cpp). Everything else is <1000. The largest amount of same scope declarations seen was 5.
llvm/lib/IR/Verifier.cpp | ||
---|---|---|
5588 | I wouldn't bother with the EXPENSIVE_CHECKS part and add a hardcoded limit of ItNext - ItCurrent < 32 or so here (only the case where there are many declares for the same scope is problematic). It would be better to instead sort by DomTree DFS In number here and thus avoid a quadratic number of checks, but I don't think it's really worthwhile (the concern is a purely theoretical one). |
llvm/lib/IR/Verifier.cpp | ||
---|---|---|
5588 |
SGTM
I was thinking about suggesting this was well, but it's probably more trouble than it is worth. |
I disabled the dominance check by default in rG3b5d36ece21f. Several buildbots show examples where this triggers, indicating there are still passes not taking care of proper handling the noalias scopes.
See:
After having reduced at least one issue, the problem originates from LoopPeel.cpp not taking care of the scopes after cloning.
I'll create a fix + testcase.
@jdoerfert I also noticed that LoopPeel.cpp is not doing anything for assumptions.
I wouldn't bother with the EXPENSIVE_CHECKS part and add a hardcoded limit of ItNext - ItCurrent < 32 or so here (only the case where there are many declares for the same scope is problematic).
It would be better to instead sort by DomTree DFS In number here and thus avoid a quadratic number of checks, but I don't think it's really worthwhile (the concern is a purely theoretical one).