[flang-commits] [flang] [flang][openmp] Fix `not yet implemented intrinsic` message for omp_lib (PR #71101)

Razvan Lupusoru via flang-commits flang-commits at lists.llvm.org
Thu Nov 2 13:13:46 PDT 2023


https://github.com/razvanlupusoru created https://github.com/llvm/llvm-project/pull/71101

PR#70386 removed hardcoded omp_lib name when checking if it is intrinsic module procedure reference - but instead relied on bind(c) to avoid generating error when the implementation is external to module.

However, this change only worked for HLFIR. Make it work for FIR flow and update the test to exercise that as well.

>From 826f7a03db993f948fd7e786716b8127794e300f Mon Sep 17 00:00:00 2001
From: Razvan Lupusoru <rlupusoru at nvidia.com>
Date: Thu, 2 Nov 2023 13:09:51 -0700
Subject: [PATCH] [flang][openmp] Fix `not yet implemented intrinsic` message
 for omp_lib

PR#70386 removed hardcoded omp_lib name when checking if it is
intrinsic module procedure reference - but instead relied on bind(c)
to avoid generating error when the implementation is external to
module.

However, this change only worked for HLFIR. Make it work for FIR flow
and update the test to exercise that as well.
---
 flang/lib/Lower/ConvertExpr.cpp                 | 3 ++-
 flang/test/Lower/OpenMP/omp-lib-num-threads.f90 | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 76d810e9df6dc2d..8c2318632f725b1 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -2534,7 +2534,8 @@ class ScalarExprLowering {
             procRef.proc().GetSpecificIntrinsic())
       return genIntrinsicRef(procRef, resultType, *intrinsic);
 
-    if (Fortran::lower::isIntrinsicModuleProcRef(procRef))
+    if (Fortran::lower::isIntrinsicModuleProcRef(procRef) &&
+        !Fortran::semantics::IsBindCProcedure(*procRef.proc().GetSymbol()))
       return genIntrinsicRef(procRef, resultType);
 
     if (isStatementFunctionCall(procRef))
diff --git a/flang/test/Lower/OpenMP/omp-lib-num-threads.f90 b/flang/test/Lower/OpenMP/omp-lib-num-threads.f90
index 01c3e93d97bfcc0..e1af7d375dfa5a8 100644
--- a/flang/test/Lower/OpenMP/omp-lib-num-threads.f90
+++ b/flang/test/Lower/OpenMP/omp-lib-num-threads.f90
@@ -1,5 +1,7 @@
 ! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - 2>&1 | FileCheck %s
 ! RUN: bbc -fopenmp -emit-hlfir -o - %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - 2>&1 | FileCheck %s
+! RUN: bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
 !
 ! Test that the calls to omp_lib's omp_get_num_threads and omp_set_num_threads
 ! get lowered even though their implementation is not in the omp_lib module



More information about the flang-commits mailing list