aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/MathExtrasTest.cpp
diff options
context:
space:
mode:
authorJulian Brown <julian.brown@amd.com>2024-08-19 14:37:32 +0100
committerGitHub <noreply@github.com>2024-08-19 09:37:32 -0400
commit3188e9b4e0f106abd683829906a21a98655bb794 (patch)
treef3cdb3bb68a094b0767ac707ff54b9e45448b586 /llvm/unittests/Support/MathExtrasTest.cpp
parenta567d4598755219e535eb04d21b43c3624526714 (diff)
downloadllvm-3188e9b4e0f106abd683829906a21a98655bb794.zip
llvm-3188e9b4e0f106abd683829906a21a98655bb794.tar.gz
llvm-3188e9b4e0f106abd683829906a21a98655bb794.tar.bz2
[clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (#101305)
This patch fixes a couple of cases where Clang aborts with loop nests that are being collapsed (via the relevant OpenMP clause) into a new, combined loop. The problematic cases happen when a variable declared within the loop nest is used in the (init, condition, iter) statement of a more deeply-nested loop. I don't think these cases (generally?) fall under the non-rectangular loop nest rules as defined in OpenMP 5.0+, but I could be wrong (and anyway, emitting an error is better than crashing). In terms of implementation: the crash happens because (to a first approximation) all the loop bounds calculations are pulled out to the start of the new, combined loop, but variables declared in the loop nest "haven't been seen yet". I believe there is special handling for iteration variables declared in "for" init statements, but not for variables declared elsewhere in the "imperfect" parts of a loop nest. So, this patch tries to diagnose the troublesome cases before they can cause a crash. This is slightly awkward because at the point where we want to do the diagnosis (SemaOpenMP.cpp), we don't have scope information readily available. Instead we "manually" scan through the AST of the loop nest looking for var decls (ForVarDeclFinder), then we ensure we're not using any of those in loop control subexprs (ForSubExprChecker). All that is only done when we have a "collapse" clause. Range-for loops can also cause crashes at present without this patch, so are handled too.
Diffstat (limited to 'llvm/unittests/Support/MathExtrasTest.cpp')
0 files changed, 0 insertions, 0 deletions