[flang-commits] [flang] [flang] Lower special bind(c) cases without binding labels (PR #65758)

via flang-commits flang-commits at lists.llvm.org
Wed Sep 20 10:34:12 PDT 2023


================
@@ -99,11 +99,14 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
 
   // TODO: A procedure that inherits BIND(C) through another interface
   // (procedure(iface)) should be dealt with in GetBindName() or some wrapper.
-  if (!Fortran::semantics::IsPointer(ultimateSymbol) &&
-      Fortran::semantics::IsBindCProcedure(ultimateSymbol) &&
-      Fortran::semantics::ClassifyProcedure(symbol) !=
-          Fortran::semantics::ProcedureDefinitionClass::Internal)
-    return ultimateSymbol.name().ToString();
+  if (const auto *procDetails{
----------------
jeanPerier wrote:

> Before I forget, did you make the name mangling target-specific?

In this patch it does not matter, the test is added at the FIR level, so non BIND(C) procedure IR name use FIR internal mangling that is target independent (start with _QP...., later transformed to target dependent names for external procedures when producing LLVM from ). The BIND(C) IR name are just the binding labels in FIR and LLVM IR.

But in previous BIND(C) patch to catch assembly conflict, yes, I had to deal with the underscoring aspect by propagating the option from the driver to semantic [here](https://github.com/llvm/llvm-project/blob/1062c140f811fabb7a926fde74112ea4d2330b74/flang/lib/Semantics/check-declarations.cpp#L2641).

> I seem to recall that XLF does not append an underscore character.

That is right, flang-new/gfortran can also do that with the -fno-undescoring option.

https://github.com/llvm/llvm-project/pull/65758


More information about the flang-commits mailing list