This is an archive of the discontinued LLVM Phabricator instance.

[ARM64EC 14/?] Set comdat for thunks and enable wowthk section to help reduce thunk numbers
Needs ReviewPublic

Authored by bcl5980 on Sep 3 2022, 7:33 AM.

Details

Reviewers
efriedma
Summary

Part of initial Arm64EC patchset.

Canonicalize type to generate thunks, then we can reuse the same name thunks generated before.
Emit thunks to .wowthk section with comdat to make the linker remove the same thunks in different obj files.

Diff Detail

Build Status
Buildable 188394

Event Timeline

bcl5980 created this revision.Sep 3 2022, 7:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 3 2022, 7:33 AM
bcl5980 requested review of this revision.Sep 3 2022, 7:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 3 2022, 7:34 AM
bcl5980 edited reviewers, added: efriedma; removed: eli.friedman.Sep 3 2022, 7:34 AM
bcl5980 updated this revision to Diff 457794.Sep 3 2022, 7:45 AM
bcl5980 updated this revision to Diff 457797.Sep 3 2022, 8:05 AM
bcl5980 edited the summary of this revision. (Show Details)Sep 3 2022, 8:06 AM
bcl5980 updated this revision to Diff 457834.Sep 3 2022, 10:20 PM

Set the thunks to external linkage.

bcl5980 updated this revision to Diff 458087.Sep 5 2022, 8:30 PM
bcl5980 updated this revision to Diff 458118.Sep 6 2022, 1:53 AM

early return if mangled name is the thunk

bcl5980 updated this revision to Diff 458127.Sep 6 2022, 3:17 AM

If struct type only have one element canonicalize it to the element type

efriedma added inline comments.Sep 13 2022, 4:54 PM
llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
245

What does "canonicalizing" like this accomplish?

llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp
89 ↗(On Diff #458127)

You shouldn't need to hack at the backend like this. Just set the section name explicitly in IR, and make the linkage linkonce_odr. That should put it in the right section with the right attributes.

bcl5980 added inline comments.Sep 21 2022, 5:05 AM
llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
245

For example int f(int) share the same thunk to char f(char).
If we want to eliminate duplicate thunks we need to map all original pow2 interger types less than 64bit to 64bit.
The goal for this function is following msvc's arm64ec thunk naming rule. Generate the thunk type from original function type.

efriedma added inline comments.Sep 21 2022, 12:09 PM
llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
245

Oh, okay, that makes sense.

bcl5980 updated this revision to Diff 462468.Sep 23 2022, 6:40 AM

Address comments.