[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-29 Thread Tavian Barnes via cfe-commits
tavianator wrote: > The expression can be simplified to ... As the padding at the end of the > structure is always smaller than the alignof. So `round_up(alignof(struct S), > offsetof(struct S, fam)) = sizeof(struct S)` I think that's right for sane ABIs. I assume Clang always lays structs ou

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-24 Thread Tavian Barnes via cfe-commits
tavianator wrote: > I mean it would be useful to round up to the alignment for when you wanne > have an array of the structs, but I'm not sure this is actually required by > the standard. Do you have more justification for the alignment requirement on > structs containing FAMs? Here's an exam

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-24 Thread Tavian Barnes via cfe-commits
tavianator wrote: For the record, I think the most correct definition, in terms of "this is how much memory you should allocate for a struct with a flexible array member" is this: ```c max( sizeof(struct S), // always at least the size of the struct itself round_up( aligno

[PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-10-11 Thread Tavian Barnes via cfe-commits
tavianator added a comment. In https://reviews.llvm.org/D21803#556857, @EricWF wrote: > @rmaprath I'll merge this if needed. Feel free to commit your patch first. Yeah, @rmaprath I'm happy to rebase this over your patch. > @tavianator Do you need somebody to merge this for you? I assume so, y

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-20 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 71934. tavianator marked an inline comment as done. tavianator added a comment. s/indended/intended/ https://reviews.llvm.org/D21803 Files: src/cxa_thread_atexit.cpp test/CMakeLists.txt test/cxa_thread_atexit_test.pass.cpp test/libcxxabi/test/con

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-15 Thread Tavian Barnes via cfe-commits
tavianator marked 5 inline comments as done. Comment at: src/cxa_thread_atexit.cpp:70 @@ +69,3 @@ +while (auto head = dtors) { + dtors = head->next; + head->dtor(head->obj); EricWF wrote: > tavianator wrote: > > EricWF wrote: > > > tavianator wrote:

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-15 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 71508. tavianator added a comment. Herald added subscribers: mgorny, beanz. Integrated @EricWF's expanded test case, and avoid an unneeded pthread_setspecific() call if the last thread_local's destructor initializes a new thread_local. https://reviews.l

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-08 Thread Tavian Barnes via cfe-commits
tavianator added inline comments. Comment at: src/cxa_thread_atexit.cpp:70 @@ +69,3 @@ +while (auto head = dtors) { + dtors = head->next; + head->dtor(head->obj); EricWF wrote: > tavianator wrote: > > EricWF wrote: > > > There is a bug here. If `head

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-07 Thread Tavian Barnes via cfe-commits
tavianator added inline comments. Comment at: src/cxa_thread_atexit.cpp:70 @@ +69,3 @@ +while (auto head = dtors) { + dtors = head->next; + head->dtor(head->obj); EricWF wrote: > There is a bug here. If `head->next == nullptr` and if > `head->dtor(h

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-06 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 70406. tavianator added a comment. Uses a __thread variable to hold the destructor list, as @EricWF suggested. https://reviews.llvm.org/D21803 Files: src/cxa_thread_atexit.cpp test/CMakeLists.txt test/cxa_thread_atexit_test.pass.cpp test/libcxxab

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-02 Thread Tavian Barnes via cfe-commits
tavianator added a comment. In https://reviews.llvm.org/D21803#532309, @EricWF wrote: > `__thread` > > What do you think of this idea? Makes sense to me, I'll integrate it into the next revision. Comment at: src/cxa_thread_atexit.cpp:42 @@ +41,3 @@ + // - thread_local destru

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-01 Thread Tavian Barnes via cfe-commits
tavianator added a comment. In https://reviews.llvm.org/D21803#530681, @bcraig wrote: > In https://reviews.llvm.org/D21803#530678, @tavianator wrote: > > > Ping? > > > Well, I still think it's fine. Maybe a direct message to @mclow.lists or > @EricWF? Is there a way to do that through Phabric

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-08-31 Thread Tavian Barnes via cfe-commits
tavianator added a comment. Ping? https://reviews.llvm.org/D21803 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-08-02 Thread Tavian Barnes via cfe-commits
tavianator added a comment. Anything else I need to do for this patch? https://reviews.llvm.org/D21803 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-07-13 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 63806. tavianator added a comment. Make sure the tail of the list is null. http://reviews.llvm.org/D21803 Files: src/cxa_thread_atexit.cpp test/CMakeLists.txt test/cxa_thread_atexit_test.pass.cpp test/libcxxabi/test/config.py test/lit.site.cfg.

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-07-13 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 63801. tavianator added a comment. Update comments to mention that late-initialized thread_locals invoke undefined behavior. http://reviews.llvm.org/D21803 Files: src/cxa_thread_atexit.cpp test/CMakeLists.txt test/cxa_thread_atexit_test.pass.cpp

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-07-08 Thread Tavian Barnes via cfe-commits
tavianator marked 9 inline comments as done. tavianator added a comment. http://reviews.llvm.org/D21803 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-07-08 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 63232. tavianator marked 6 inline comments as done. tavianator added a comment. - Bring back HAVE___CXA_THREAD_ATEXIT_IMPL, and avoid the weak symbol/fallback implementation in that case - Fix a leak in an error path - Add a CreatesThreadLocalInDestructor

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-07-05 Thread Tavian Barnes via cfe-commits
tavianator added inline comments. Comment at: src/cxa_thread_atexit.cpp:47 @@ +46,3 @@ +// called during the loop. +if (pthread_setspecific(dtors, ptr) != 0) { + abort_message("pthread_setspecific() failed during thread_local destruction"); bcraig wr

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-07-04 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 62691. tavianator added a comment. Added a test case for destructor ordering. Got rid of pthread_{get,set}specific in a loop. http://reviews.llvm.org/D21803 Files: cmake/config-ix.cmake src/CMakeLists.txt src/cxa_thread_atexit.cpp test/CMakeLis

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-06-30 Thread Tavian Barnes via cfe-commits
tavianator added inline comments. Comment at: src/cxa_thread_atexit.cpp:47 @@ +46,3 @@ + void run_dtors(void* ptr) { +if (pthread_setspecific(dtors, ptr) != 0) { + abort_message("pthread_setspecific() failed during thread_local destruction"); bcraig wro

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-06-30 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 62394. tavianator added a comment. Fix copy-pasta that result in an infinite loop. http://reviews.llvm.org/D21803 Files: cmake/config-ix.cmake src/CMakeLists.txt src/cxa_thread_atexit.cpp test/CMakeLists.txt test/cxa_thread_atexit_test.pass.cpp

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-06-30 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 62388. tavianator added a comment. Added missing __dso_handle declaration. http://reviews.llvm.org/D21803 Files: cmake/config-ix.cmake src/CMakeLists.txt src/cxa_thread_atexit.cpp test/CMakeLists.txt test/cxa_thread_atexit_test.pass.cpp test/

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-06-30 Thread Tavian Barnes via cfe-commits
tavianator marked 3 inline comments as done. tavianator added a comment. In http://reviews.llvm.org/D21803#470448, @bcraig wrote: > What that means for this implementation is that I think that > _cxa_thread_atexit is allowed to be called during run_dtors. If running the > dtor for a thread loc

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-06-30 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 62386. tavianator added a comment. Fixed some corner cases regarding destruction order and very-late-initialized thread_locals. Explicitly documented the known limitations compared to __cxa_thread_atexit_impl(). http://reviews.llvm.org/D21803 Files:

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-06-29 Thread Tavian Barnes via cfe-commits
tavianator added a comment. In http://reviews.llvm.org/D21803#470086, @bcraig wrote: > It also intentionally leaks the pthread key. Does the __thread_specific_ptr > rationale hold for this change as well? Hmm, maybe? If other global destructors run after ~DtorListHolder(), and they cause a

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-06-29 Thread Tavian Barnes via cfe-commits
tavianator added a comment. In http://reviews.llvm.org/D21803#469988, @bcraig wrote: > You should look at __thread_specific_ptr in libcxx's . It does a lot > of these things in order to satisfy the requirements of > notify_all_at_thread_exit, set_value_at_thread_exit, and > make_ready_at_thre

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-06-29 Thread Tavian Barnes via cfe-commits
tavianator updated this revision to Diff 62218. tavianator added a comment. Added error handling for pthread_key uses http://reviews.llvm.org/D21803 Files: cmake/config-ix.cmake src/CMakeLists.txt src/cxa_thread_atexit.cpp test/CMakeLists.txt test/cxa_thread_atexit_test.pass.cpp tes

Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-06-28 Thread Tavian Barnes via cfe-commits
tavianator added inline comments. Comment at: src/cxa_thread_atexit.cpp:36-47 @@ +35,14 @@ + public: +DtorListHolder() { + pthread_key_create(&key_, run_dtors); +} + +~DtorListHolder() { + run_dtors(get()); + pthread_key_delete(key_); +} + +Dtor

[PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-06-28 Thread Tavian Barnes via cfe-commits
tavianator created this revision. tavianator added reviewers: danalbert, jroelofs. tavianator added a subscriber: cfe-commits. Herald added subscribers: danalbert, tberghammer. __cxa_thread_atexit_impl() isn't present on all platforms, for example Android pre-6.0. This patch uses a weak symbol to

Re: [PATCH] D12834: add gcc abi_tag support

2016-01-05 Thread Tavian Barnes via cfe-commits
tavianator added a subscriber: tavianator. Comment at: lib/AST/ItaniumMangle.cpp:1120 @@ -880,2 +1119,3 @@ mangleSourceName(qualifier->getAsIdentifier()); +writeAbiTags(qualifier->getAsNamespaceAlias()); break; This looks bogus, should be `writeAbiTa