This patch adds user option -funderscoring/-fnounderscoring to control the trailing underscore being appended to external names (e.g. procedure names, common block names). The option in gfortran is documented in https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html.
Details
Diff Detail
Event Timeline
Hi @madanial , thanks for posting this!
This patch adds user option -funderscoring/-fnounderscoring which behaves similar to the gfortran option be enabling/disabling the ExternalNameConversionPass
I don't quite understand what this option is for and it's hard to deduce from the patch. Please, could you add a link to some documentation? And tests.
-Andrzej
@awarzynski Thanks for the review. @madanial will not be available for the next few weeks. I will try to address some review comments while he is away.
The purpose of this option is to control the trailing underscore being appended to external names (e.g. procedure names, common block names). The option in gfortran is documented in https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html.
However, I don't think the patch does what we want. Given a procedure name foo, the -fno-underscoring option will give _QPfoo instead of foo. We will look into it.
However, I don't think the patch does what we want. Given a procedure name foo, the -fno-underscoring option will give _QPfoo instead of foo.
Thanks for this explanation - much appreciated! Could this short description be added to the summary? Also, could you add a note stating whether the semantics of this option in Flang are consistent with GFortran. Ta!
However, I don't think the patch does what we want. Given a procedure name foo, the -fno-underscoring option will give _QPfoo instead of foo. We will look into it.
Names in Flang are mangled at the FIR level. I couldn't find any documentation for this, but the ExternalNameConversion pass could be helpful.
@awarzynski Thanks for the info. We intend to make use of ExternalNameConversion for this purpose. However, we are not sure how a compiler option can control the behavior in ExternalNameConversion. Any pointer to how other passes do it is appreciated.
You should have a look at https://mlir.llvm.org/docs/PassManagement/#instance-specific-pass-options
Implementing functionality to control just the trailing underscore for external names to achieve similar functionality to the option in gfortran, as well as rebase and address review comments.
Small suggestion
flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp | ||
---|---|---|
41–45 | To avoid new copy |
Rebase, as well as bug fix relating to the ExternalNameConversion pass option that was exposed by the requested fir-opt test case. The pass option was being overwritten by default value whenever it was called through fir-opt.
The pre-commit check is still failing with these tests:
Flang :: Fir/alloc.fir
Flang :: Fir/embox.fir Flang :: Fir/optional.fir Flang :: Fir/rebox.fir Flang :: Lower/common-block.f90 Flang :: Lower/forall/character-1.f90
Please follow the same formatting in this file.