This is an archive of the discontinued LLVM Phabricator instance.

[mlir][func] Use internal linkage for C wrapper of external functions.
AbandonedPublic

Authored by ingomueller-net on Jun 19 2023, 3:08 AM.

Details

Summary

If a declaration of an externally defined function has the
llvm.emit_c_interface attribute, a wrapper function is created with
the same name that calls the corresponding function with the C interface
(which has the same name prefixed with _mlir_ciface_). This way, the
original code can use the non-C-interface under the original name but
call the C interface of the function transparently. However, until now,
that wrapper function was created with external linkage, so it would
collide if the library provided a (non-C-interface) function under the
original name. Since the wrapper is only needed for the current module,
it should, in fact, have internal linkage. This patch, thus, sets the
linkage of the function with the original name to internal unless the
linkage is set with the llvm.linkage attribute, in which case that is
used.

Diff Detail