This is an archive of the discontinued LLVM Phabricator instance.

[Mangler] Mangle aliases to fastcall/vectorcall functions correctly
ClosedPublic

Authored by Amanieu on Feb 22 2022, 7:59 PM.

Details

Summary

These aliases are produced by MergeFunctions and need to be mangled according to the calling convention of the function they are pointing to instead of defaulting to the C calling convention.

Diff Detail

Event Timeline

Amanieu created this revision.Feb 22 2022, 7:59 PM
Amanieu requested review of this revision.Feb 22 2022, 7:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2022, 7:59 PM
Amanieu updated this revision to Diff 410789.Feb 23 2022, 5:51 AM

Fixed to use dyn_cast_or_null.

Amanieu added a reviewer: rnk.Feb 23 2022, 6:13 AM
rnk added a comment.Feb 25 2022, 1:19 PM

I have some misgivings about this, but I think this is probably the best way forward for now.

I think it was always a mistake to do IR mangling based on the calling convention and prototype. However, that's what we do, and removing that is a long process. FWIW clang never relies on the IR mangler for functions like this, it does the mangling itself.

The other way to handle this is to teach merge functions to do IR mangling. Merge functions can create a Mangler object with the DataLayout from the Module. Then it can create escaped aliases with names like "\01@foo@20". After thinking about it, I think I prefer your approach, despite the surprising behavior.

In the long run, I would like to remove this calling convention mangling altogether, at which point this change will be deleted.

rnk accepted this revision.Feb 25 2022, 1:19 PM

lgtm

This revision is now accepted and ready to land.Feb 25 2022, 1:19 PM
This revision was landed with ongoing or failed builds.Feb 25 2022, 2:11 PM
This revision was automatically updated to reflect the committed changes.

For context, I encountered a linker error caused by this in Rust which does use the IR mangler.