[flang-commits] [flang] 247bad1 - [flang][hlfir] probe ultimate intrinsic module procedure name

Jean Perier via flang-commits flang-commits at lists.llvm.org
Fri Jun 30 11:27:49 PDT 2023


Author: Jean Perier
Date: 2023-06-30T20:27:05+02:00
New Revision: 247bad1671a8229929a584ff0db788cf9e56e02a

URL: https://github.com/llvm/llvm-project/commit/247bad1671a8229929a584ff0db788cf9e56e02a
DIFF: https://github.com/llvm/llvm-project/commit/247bad1671a8229929a584ff0db788cf9e56e02a.diff

LOG: [flang][hlfir] probe ultimate intrinsic module procedure name

HLFIR lowering was currently hitting errors like "not yet implemented:
intrinsic: z0$iso_c_binding$c_associated_c_ptr". These error were caused
by HLFIR lowering using the name with the full context instead of
the ultimate one.
I do not want to change proc.GetName() because I think it may be best
if it retains the full context for its usages in semantics, so I fixed
the helper to get the name in lowering to HLFIR.

Differential Revision: https://reviews.llvm.org/D154230

Added: 
    

Modified: 
    flang/lib/Lower/ConvertCall.cpp
    flang/test/Lower/HLFIR/intrinsic-module-procedures.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index 46fc480bb1b5f5..626d9ef0f706e0 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -583,7 +583,11 @@ struct CallContext {
 
   fir::FirOpBuilder &getBuilder() { return converter.getFirOpBuilder(); }
 
-  std::string getProcedureName() const { return procRef.proc().GetName(); }
+  std::string getProcedureName() const {
+    if (const Fortran::semantics::Symbol *sym = procRef.proc().GetSymbol())
+      return sym->GetUltimate().name().ToString();
+    return procRef.proc().GetName();
+  }
 
   /// Is this a call to an elemental procedure with at least one array argument?
   bool isElementalProcWithArrayArgs() const {

diff  --git a/flang/test/Lower/HLFIR/intrinsic-module-procedures.f90 b/flang/test/Lower/HLFIR/intrinsic-module-procedures.f90
index e7d8536871e550..6406d00bebb592 100644
--- a/flang/test/Lower/HLFIR/intrinsic-module-procedures.f90
+++ b/flang/test/Lower/HLFIR/intrinsic-module-procedures.f90
@@ -21,3 +21,14 @@ subroutine foo(cptr, x)
 ! CHECK:         %[[VAL_8:.*]] = fir.box_addr %[[VAL_4]] : (!fir.box<i32>) -> !fir.ref<i32>
 ! CHECK:         %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.ref<i32>) -> i64
 ! CHECK:         fir.store %[[VAL_9]] to %[[VAL_7]] : !fir.ref<i64>
+
+subroutine test_renaming(p)
+  use iso_c_binding, only: c_associated_alias => c_associated, c_ptr
+  type(c_ptr) p
+  print *, c_associated_alias(p)
+end subroutine
+
+! CHECK-LABEL: func.func @_QPtest_renaming
+! CHECK:  %[[C_PTR_TARG:.*]] = fir.load %{{.*}} : !fir.ref<i64>
+! CHECK:  %[[NULL:.*]] = arith.constant 0 : i64
+! CHECK:  arith.cmpi ne, %[[C_PTR_TARG]], %[[NULL]] : i64


        


More information about the flang-commits mailing list