New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
absl::is_trivially_relocatable now respects assignment operators #1625
Conversation
Trivial relocatability also requires that the type not do anything weird with its assignment operator; update the type-trait to reflect this. (This is the definition used by BSL, Folly, HPX, Thrust, Parlay, Amadeus, and P1144.) This is important if we want to use `absl::is_trivially_relocatable` as a gate for memcpy optimizations in `inlined_vector::erase` and/or `inlined_vector::swap`, because in those cases relocation is used to replace part of a sequence involving assignment; the optimization requires an assignment operator that behaves value-semantically. Clang's builtin currently fails to check the assignment operator, so we stop using it entirely for now. We already refused to use it on Win32, Win64, and Apple, for various unrelated reasons. I'm working on giving Clang's builtin the behavior that would let us re-enable it here. Assume that any compiler providing both `__cpp_impl_trivially_relocatable` and a builtin `__is_trivially_relocatable(T)` will use the appropriate (P1144) definition for its builtin. Right now there's only one such compiler (the P1144 reference implementation, which forks Clang), so this is largely a moot point, but I'm being optimistic.
Thanks. I'm going to try to import this first, then I'll work on the others. |
@derekmauro (or @jacobsa if he's around), just a question: When you turned off the builtin for Windows Clang, why didn't you file a bug against upstream Clang? Would one of you be willing to file an upstream bug at this point? 6b4af24 <-- the Abseil commit that identifies the upstream bug (I think what Clang's doing is noticing that the Windows calling convention, unlike the Linux one, allows |
Sorry, I should have said in the public commit that I did report this Google-internally (as bug 275003464). I'm not an expert on Windows toolchains, and at the time I thought it might be only a Google-internal toolchain. @rnk had some thoughts in that thread, and might be able to say more publicly. |
Update: This is not trivial to import. I've found a small number of tests that that rely on |
It looks like I did write this up and file an issue for it: llvm/llvm-project#69394 |
Hi @rnk! I've split out the relevant part of my Clang fork into this commit: Quuxplusone/llvm-project@47859e7 |
My problem is that I'm really bad at pushing things upstream (a symptom of mostly working internally). For instance, like that time I dragged my feet on pushing your std::vector change to optimize for trivially relocatable types until someone else ended up reimplementing it from scratch. Realistically, would prefer if someone better at contributing to open source projects did it. |
I'm interested in helping to land that Clang patch! What is the first step? |
@AMP999 My current patch is linked from my comment above. I'd say the first step is to turn it into a PR to https://github.com/llvm/llvm-project/pulls , and then ping llvm/llvm-project#69394 (for the benefit of any Abseilers who might be watching that issue). Then we'd hope that the folks here and at Folly (if not other places too) would take the opportunity to review the patch and weigh in as to whether it would fully suit their libraries' needs. As long as you're willing and able to move it forward and can deal with review comments, that sounds perfect to me. |
@Quuxplusone Okay, I've filed a PR for the builtin's behaviour! With some changes in the code, though. |
@AMP999: Awesome! That PR looks great to me. Hopefully someone from Abseil will also take a look and leave a comment, soon. Abseil certainly ought to have a vested interest in getting the Clang builtin up to speed, because it would help a lot of Abseil-using code. (At least when compiled with Clang 19+.) :) If the patch is accepted, then we (well, @derekmauro @rnk @jacobsa) should definitely consider re-enabling Abseil's use of the builtin on Clang 19-and-greater. |
Update: Abseil commit df2c771 had already disabled @derekmauro could you please take a look at llvm/llvm-project#84621 and leave a comment from Abseil, or at least give your 👍 to encourage Clang 19 to adopt the patch? Thanks very much! |
…t operators Imported from GitHub PR abseil#1625 Trivial relocatability also requires that the type not do anything weird with its assignment operator; update the type-trait to reflect this. (This is the definition used by BSL, Folly, HPX, Thrust, Parlay, Amadeus, and P1144.) This is important if we want to use `absl::is_trivially_relocatable` as a gate for memcpy optimizations in `inlined_vector::erase` and/or `inlined_vector::swap`, because in those cases relocation is used to replace part of a sequence involving assignment; the optimization requires an assignment operator that behaves value-semantically. Clang's builtin currently fails to check the assignment operator, so we stop using it entirely for now. We already refused to use it on Win32, Win64, and Apple, for various unrelated reasons. I'm working on giving Clang's builtin the behavior that would let us re-enable it here. Assume that any compiler providing both `__cpp_impl_trivially_relocatable` and a builtin `__is_trivially_relocatable(T)` will use the appropriate (P1144) definition for its builtin. Right now there's only one such compiler (the P1144 reference implementation, which forks Clang), so this is largely a moot point, but I'm being optimistic. Merge d943abd into 34604d5 Merging this change closes abseil#1625 COPYBARA_INTEGRATE_REVIEW=abseil#1625 from Quuxplusone:trivially-relocatable d943abd PiperOrigin-RevId: 607977323 Change-Id: I6436a60326c6d1064bdd71ec2e15b86b7a29efd4
Trivial relocatability also requires that the type not do anything weird with its assignment operator; update the type-trait to reflect this. (This is the definition used by BSL, Folly, HPX, Thrust, Parlay, Amadeus, and P1144.)
This is important if we want to use
absl::is_trivially_relocatable
as a gate for memcpy optimizations ininlined_vector::erase
and/orinlined_vector::swap
, because in those cases relocation is used to replace part of a sequence involving assignment; the optimization requires an assignment operator that behaves value-semantically.Clang's builtin currently fails to check the assignment operator, so we stop using it entirely for now. We already refused to use it on Win32, Win64, and Apple, for various unrelated reasons. I'm working on giving Clang's builtin the behavior that would let us re-enable it here.
Assume that any compiler providing both
__cpp_impl_trivially_relocatable
and a builtin__is_trivially_relocatable(T)
will use the appropriate (P1144) definition for its builtin. Right now there's only one such compiler (the P1144 reference implementation, which forks Clang), so this is largely a moot point, but I'm being optimistic.