This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Use [[no_unique_address]] in __alloc_func
AbandonedPublic

Authored by philnik on Feb 8 2022, 1:30 PM.

Details

Reviewers
ldionne
Quuxplusone
Mordante
Group Reviewers
Restricted Project
Summary

And some code cleanup

Diff Detail

Event Timeline

philnik requested review of this revision.Feb 8 2022, 1:30 PM
philnik created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2022, 1:30 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
jloser added a subscriber: jloser.Feb 8 2022, 1:41 PM

FWIW, I would not mix NFC code reformatting with an unrelated change (like marking the allocator member with [[no_unique_address]]). I'd prefer to just make the two-line change in this PR, and then an NFC reformat PR as a follow-up.

FWIW, I would not mix NFC code reformatting with an unrelated change (like marking the allocator member with [[no_unique_address]]). I'd prefer to just make the two-line change in this PR, and then an NFC reformat PR as a follow-up.

I have to edit every single function anyways, but maybe it would be better.

ldionne requested changes to this revision.Feb 8 2022, 1:55 PM

Unfortunately, we can't make this change because it breaks the ABI. We can't modify the layout of __alloc_func because existing programs could have inlined assumptions about its layout.

The layout changes notably for empty classes that are final -- those won't be elided with __compressed_pair, but they will with [[no_unique_address]].

libcxx/include/__functional/function.h
137

Does Clang really support this in earlier standards?

This revision now requires changes to proceed.Feb 8 2022, 1:55 PM
philnik abandoned this revision.Feb 8 2022, 2:35 PM

Unfortunately, we can't make this change because it breaks the ABI. We can't modify the layout of __alloc_func because existing programs could have inlined assumptions about its layout.

The layout changes notably for empty classes that are final -- those won't be elided with __compressed_pair, but they will with [[no_unique_address]].

That really is unfortunate.

libcxx/include/__functional/function.h
137