================
@@ -585,12 +602,155 @@ void OmpStructureChecker::Leave(const
parser::OmpDirectiveSpecification &x) {
void OmpStructureChecker::Enter(const parser::OmpMetadirectiveDirective &x) {
EnterDirectiveNest(MetadirectiveNest);
+ metadirectiveLoopVariants_.clear();
}
void OmpStructureChecker::Leave(const parser::OmpMetadirectiveDirective &) {
ExitDirectiveNest(MetadirectiveNest);
}
+// Return true if the variant guarded by `selector` might be selected on this
+// compilation target, so its associated loop must still be checked.
+static bool mayVariantBeSelected(
+ const parser::traits::OmpContextSelectorSpecification *selector,
+ SemanticsContext &context, OmpVariantMatchContext &matchContext) {
+ if (context.targetTriple().empty() || !selector ||
+ FindUnsupportedSelectorFeature(*selector, context) !=
+ UnsupportedSelectorFeature::None) {
+ return true;
+ }
+ llvm::omp::VariantMatchInfo vmi;
+ (void)MakeVariantMatchInfo(vmi, *selector, context);
+ return llvm::omp::isVariantApplicableInContext(
----------------
Saieiei wrote:
Could we also skip variants where `user={condition(...)}` folds to
`user_condition_false`?
I reproduced a false-positive with PR-head `flang`: this emits the
`collapse(3)` depth diagnostic, even though the `when` variant is statically
unselectable and `default(nothing)` should apply.
```fortran
subroutine cond_false_static(n, a)
integer :: n, a(n, n), i, j
logical, parameter :: use_variant = .false.
!$omp metadirective when(user={condition(use_variant)}: do collapse(3))
default(nothing)
do i = 1, n
do j = 1, n
a(j, i) = i
end do
end do
end subroutine
https://github.com/llvm/llvm-project/pull/207088
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits