Hi Sandra,
Sandra Loosemore wrote:
The OpenMP specification says that name mangling is supposed to encode
the context selector for the variant, but also provides for no way to
reference these functions directly by name or from a different
compilation unit. It also gives no guidance on how dynamic selectors
might be encoded across compilation units.
The GCC implementation of this feature instead treats variant
functions as if they have no linkage and uses a simple counter to
generate names.
... Except for (Fortran and) C++ modules, but those the module
name is included in the mangling.
I think you should mention this in some way in the change log.
(Note to readers: this is implemented in this patch + the C++ Patch 3/6.)
This matches the following from this patch (comment above the
function 'omp_mangle_variant_name'):
+ C++ modules are an exception to this, as variants in a module interface
+ unit are visible to implementation TUs for that module. This is handled
+ in the C++ front end by adding an additional prefix to SEP for variants
+ in a module interface to prevent collisions with names in the other TUs. */
However, reading it, I was a bit confused about not mentioning the module name.
(It gets added after the mangling automatically by the FE.) Additionally, I
wonder whether we should already mention Fortran, albeit it is not yet
implemented and new with OpenMP 6.1 (and, before, in TR14).
Namely, I think first 'C++' should be changed to 'C++ and Fortran' and
something like the following sentence should be added at the end:
"Additionally, the Fortran and C++ front ends add the module name to the
mangled names."
(For Fortran, that's based on the assumption that we will implement it
using this function and that we will forget about updating this comment
before. - But one can argue about this and leave Fortran out.)
* * *
gcc/ChangeLog
* omp-general.cc (omp_mangle_variant_name): New.
(omp_check_for_duplicate_variant): New.
(omp_copy_trait_set): New.
(omp_trait_selectors_equivalent): New.
(omp_combine_trait_sets): New.
(omp_merge_context_selectors): New.
* omp-general.h (omp_mangle_variant_name): Declare.
(omp_check_for_duplicate_variant): Declare.
(omp_merge_context_selectors): Declare.
LGTM - albeit consider the comment about the comment and the ChangeLog.
For omp_combine_trait_sets, I think it is okay – but I guess I should
play a bit around once enough has been merged to play around.
Tobias