This is an archive of the discontinued LLVM Phabricator instance.

[libcxxabi] Pulled guard byte code out of GuardObject
ClosedPublic

Authored by DanielMcIntosh-IBM on Dec 8 2021, 11:30 AM.

Details

Summary

Right now, GuardObject is in charge of both reading and writing to the guard
byte, and co-ordinating with the InitByte... classes. In order to improve
separation of concerns, create a separate class responsible for managing the
guard byte and use that inside GuardObject.

This is the 3rd of 5 changes to overhaul cxa_guard.
See D108343 for what the final result will be.

Depends on D110088

Diff Detail

Event Timeline

DanielMcIntosh-IBM requested review of this revision.Dec 8 2021, 11:30 AM
DanielMcIntosh-IBM created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2021, 11:30 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Fix copy-paste error from re-organization of reviews

ldionne added inline comments.Dec 13 2021, 7:45 AM
libcxxabi/src/cxa_guard_impl.h
15

This is confusing me -- does the compiler really check the guard byte? Isn't it what we do in the library when we do guard_byte.load(std::_AO_Acquire) != UNSET?

232
DanielMcIntosh-IBM marked an inline comment as done.Dec 13 2021, 9:48 AM
DanielMcIntosh-IBM added inline comments.
libcxxabi/src/cxa_guard_impl.h
15

Yes, for performance reasons we check it inline before calling __cxa_guard_acquire: https://godbolt.org/z/hY1555Wcx. I believe in clang this is generated around clang/lib/CodeGen/ItaniumCXXABI.cpp:2470. As you point out, we also check it inside __cxa_guard_acquire, I assume this is in case the library is used with a compiler that doesn't generate the inline check (or something along those lines).

ldionne accepted this revision.Dec 13 2021, 11:35 AM

Please rebase onto main and make sure you have a green CI run.

libcxxabi/src/cxa_guard_impl.h
15

Thanks for the information!

This revision is now accepted and ready to land.Dec 13 2021, 11:35 AM

No change, just rebase and re-trigger CI to update base revision

DanielMcIntosh-IBM edited the summary of this revision. (Show Details)Jan 10 2022, 2:18 PM
DanielMcIntosh-IBM retitled this revision from [NFC][libcxxabi] Pulled guard byte code out of GuardObject to [libcxxabi] Pulled guard byte code out of GuardObject.Jan 12 2022, 11:18 AM