[flang-commits] [flang] [flang][OpenMP] Lowering support for declare variant. (PR #206988)
Abid Qadeer via flang-commits
flang-commits at lists.llvm.org
Fri Jul 3 08:24:52 PDT 2026
================
@@ -0,0 +1,200 @@
+! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-version=51 %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=51 %s -o - | FileCheck %s
+
+! Lowering tests for DECLARE VARIANT callee resolution at call sites.
+! The declarative directive is not lowered; variant selection rewrites
+! procedure calls inside matching OpenMP regions.
+
+subroutine test_sequential_vs_parallel
+ call base()
+ !$omp parallel
+ call base()
+ !$omp end parallel
+end subroutine test_sequential_vs_parallel
+
+subroutine base
+ !$omp declare variant (base:vsub) match (construct={parallel})
+contains
+ subroutine vsub
+ end subroutine
+end subroutine base
----------------
abidh wrote:
I have added a check for this case, plus a test that exercises the error. The other tests have been updated accordingly, and I have organized them to cover all the valid configurations:
1. Base and variant are sibling module procedures.
2. Base and variant are internal procedures of the same host.
3. Base and variant are both external procedures.
4. Base is an external procedure and the variant is a use-associated module
procedure.
https://github.com/llvm/llvm-project/pull/206988
More information about the flang-commits
mailing list