Page MenuHomePhabricator

jplayer-nv (James Player)
User

Projects

User does not belong to any projects.

User Details

User Since
Dec 17 2020, 4:00 PM (119 w, 1 d)

Recent Activity

Oct 30 2022

jplayer-nv added a comment to D134675: [ADT] Make mapped_iterator copy assignable.

Author name = James Player
Email = james.w.player@gmail.com

Oct 30 2022, 1:57 PM · Restricted Project, Restricted Project

Oct 24 2022

jplayer-nv added a comment to D134675: [ADT] Make mapped_iterator copy assignable.

Ping @kazu for commit. If you're not the right person to ask, could you kindly suggest someone else?

Oct 24 2022, 6:48 PM · Restricted Project, Restricted Project

Oct 12 2022

jplayer-nv added a comment to D134675: [ADT] Make mapped_iterator copy assignable.

Thanks for the review @kazu

Oct 12 2022, 9:25 PM · Restricted Project, Restricted Project

Sep 26 2022

jplayer-nv added a reviewer for D134675: [ADT] Make mapped_iterator copy assignable: kazu.
Sep 26 2022, 4:21 PM · Restricted Project, Restricted Project
jplayer-nv updated the summary of D134675: [ADT] Make mapped_iterator copy assignable.
Sep 26 2022, 2:48 PM · Restricted Project, Restricted Project
jplayer-nv requested review of D134675: [ADT] Make mapped_iterator copy assignable.
Sep 26 2022, 2:21 PM · Restricted Project, Restricted Project

Sep 19 2022

jplayer-nv added a comment to D134076: RFC - [ADT] Ranges pipe syntax support + SFINAE.

My gut reaction is that this is quite a lot of API surface area to add without current or near-future planned usage.

Any chance you're interested in proposing this as part of a patch series to at least migrate some of the existing iterator-adaptor or custom algorithms to this usage? (@kazu - maybe this'd be of some interest to you too?)

I'd be happy to break this down into bite-sized chunks. Is discourse the right place to iterate on the details of such a patch series? I can start with the ability to default construct and copy-assign existing iterators which carry a callable.

Sep 19 2022, 12:18 PM · Restricted Project, Restricted Project

Sep 16 2022

jplayer-nv added a comment to D134076: RFC - [ADT] Ranges pipe syntax support + SFINAE.

I wrote this code for a private target (as well as for a non-LLVM compiler framework), and was wondering if some form of it would be useful upstream (I fully expect some high-level refactoring). It seems strange that there are things defined in STLExtras.h which mimic the behavior of std::ranges elements but are named differently (mapped_iterator vs transform_iterator for example).

Sep 16 2022, 2:24 PM · Restricted Project, Restricted Project
jplayer-nv requested review of D134076: RFC - [ADT] Ranges pipe syntax support + SFINAE.
Sep 16 2022, 2:09 PM · Restricted Project, Restricted Project

Apr 29 2022

jplayer-nv added a comment to D112175: [NFC] Add llvm::StaticVector ADT.

If your host toolchain has C++17, I'd be curious if the regression goes away when you switch to that mode and use if constexpr.

I'd also be curious how this performs on your benchmark (after you fix the compiler errors / etc.):

template <class U, std::enable_if_t<U::TakesParamByValue, bool> = false>
static const T *reserveForParamAndGetAddressImpl(U *This, const T &Elt,
                                                 size_t N) {
  size_t NewSize = This->size() + N;
  if (LLVM_LIKELY(NewSize <= This->capacity()))
    return &Elt;

  This->grow(NewSize);
  return &Elt;
}
template <class U, std::enable_if_t<!U::TakesParamByValue, bool> = false>
static const T *reserveForParamAndGetAddressImpl(U *This, const T &Elt,
                                                 size_t N) {
  size_t NewSize = This->size() + N;
  if (LLVM_LIKELY(NewSize <= This->capacity()))
    return &Elt;

  bool ReferencesStorage = false;
  int64_t Index = -1;
  if (!U::TakesParamByValue) {
    if (LLVM_UNLIKELY(This->isReferenceToStorage(&Elt))) {
      ReferencesStorage = true;
      Index = &Elt - This->begin();
    }
  }
  This->grow(NewSize);
  return ReferencesStorage ? This->begin() + Index : &Elt;
}

Seems like it should be mostly equivalent to your solution, but the specialization is at a lower level where it's easy to verify the logic is equivalent... and it's also still obvious how if constexpr would apply once we have it.

Apr 29 2022, 2:18 PM · Restricted Project, Restricted Project
jplayer-nv added a comment to D112175: [NFC] Add llvm::StaticVector ADT.

Ideally the outer if would be if constexpr(!U::TakesParamByValue) but that needs to wait for C++17.

The current implementation is easy to verify since the check is just in one place. Is it just a synthetic benchmark where it's causing a slowdown? Or, can we help the optimizer along somehow without changing the layering? (I don't feel strongly attached to exact design of the current thing, but IIRC it took some compromise at the time to make everyone happy. But I could be remembering the patch series incorrectly.)

Apr 29 2022, 10:49 AM · Restricted Project, Restricted Project

Apr 28 2022

jplayer-nv added a comment to D112175: [NFC] Add llvm::StaticVector ADT.
[ RUN      ] StaticVsSmall/0.TimedStaticVector
[       OK ] StaticVsSmall/0.TimedStaticVector (371 ms)
[ RUN      ] StaticVsSmall/0.TimedSmallVector
[       OK ] StaticVsSmall/0.TimedSmallVector (596 ms)

Which demonstrates that simple insertions are significantly faster (almost 38%) with the StaticVector compared to a SmallVector which stays within its small buffer limit.

Apr 28 2022, 9:02 PM · Restricted Project, Restricted Project
jplayer-nv added a comment to D112175: [NFC] Add llvm::StaticVector ADT.

Just to give a concrete example of what I believe to be the benefit behind StaticVector, I ran this contrived test pitting SmallVector<uint64_t,N> vs StaticVector<uint64_t,N> (with a few tweaks to ensure the push_back param is passsed by value like in SmallVector):

TYPED_TEST(StaticVsSmall, TimedStaticVector) {
  const size_t N = this->NumBuiltinElts(this->TheStaticVector);
  for (int I = 0; I < OutterLimit; ++I) {
    this->TheStaticVector.clear();
    for (int J = 0; J < N; ++J) {
      this->TheStaticVector.push_back(I + J);
    }
  }
}
Apr 28 2022, 12:11 PM · Restricted Project, Restricted Project
jplayer-nv updated the diff for D112175: [NFC] Add llvm::StaticVector ADT.

Call llvm::consumeError() when an Error is returned in the StaticVector unit test.

Apr 28 2022, 10:27 AM · Restricted Project, Restricted Project

Apr 27 2022

jplayer-nv updated the diff for D112175: [NFC] Add llvm::StaticVector ADT.

Resurrecting this review for the following:

Apr 27 2022, 3:13 PM · Restricted Project, Restricted Project

Jan 18 2022

jplayer-nv added a comment to D115443: [ADT] Weaken the initialization condition in SmallVector::resize_for_overwrite.

It can be/probably is useful for the API to be there, but be a no-op - so that it can be used in generic code (eg: in templates that don't know if they're operating on trivial or non-trivial element types, they call it, then carry on - for non-trivial types it doesn't do anything, for trivial ones it provides some performance improvement opportunities).

Jan 18 2022, 4:26 PM · Restricted Project
jplayer-nv added a comment to D115443: [ADT] Weaken the initialization condition in SmallVector::resize_for_overwrite.

My concern would be the variations in the result of std::is_trivially_copyable across different c++ standards. It's possible that you could have a class considered non-trivially copyable in one compiler and trivially copyable in another. This means that it becomes unclear whether you can populate the buffer with std::uninitialized_copy or you should call std::copy (for example).

But is this really a problem? If std::is_trivially_copyable isn't aggressive you get redundant initializations, but it's not a bug. ABI-wise this should also be fine because no struct layout is affected.

Jan 18 2022, 1:58 PM · Restricted Project

Jan 13 2022

jplayer-nv added a comment to D115443: [ADT] Weaken the initialization condition in SmallVector::resize_for_overwrite.

Older MSVC has trouble with is_trivially_copyable

Jan 13 2022, 6:02 PM · Restricted Project
jplayer-nv accepted D117254: [ADT] Fix Optional<> with llvm::is_trivially_move_constructible.

we also do not have a LLVM version of that implementation.

Jan 13 2022, 5:39 PM · Restricted Project
jplayer-nv added inline comments to D117254: [ADT] Fix Optional<> with llvm::is_trivially_move_constructible.
Jan 13 2022, 3:52 PM · Restricted Project

Oct 27 2021

jplayer-nv added a comment to D112175: [NFC] Add llvm::StaticVector ADT.

Here's another example of a possible StaticVector conversion:

Oct 27 2021, 12:02 PM · Restricted Project, Restricted Project
jplayer-nv added a comment to D112175: [NFC] Add llvm::StaticVector ADT.

I'd grep for std::array<llvm::Optional<...>, ...> — I suppose this would be a good replacement for at least some instances of that.

Oct 27 2021, 11:24 AM · Restricted Project, Restricted Project

Oct 21 2021

jplayer-nv updated the diff for D112175: [NFC] Add llvm::StaticVector ADT.
  • Define the MSVC visualizer for StaticVector.
  • Bind StaticVector a simple yaml sequence.
  • Change StaticVector::Capacity to an enum to make it available from the visualizer.
  • Substitute some SmallVectors which never grow beyond inline storage.
Oct 21 2021, 3:53 PM · Restricted Project, Restricted Project
jplayer-nv added a comment to D112175: [NFC] Add llvm::StaticVector ADT.

I don't see too many simple substitutions in target independent code, although this class has a SmallVector which never exceeds the inline storage (drop-in type substitution + with YAML binding works):

Oct 21 2021, 2:50 PM · Restricted Project, Restricted Project

Oct 20 2021

jplayer-nv updated the diff for D112175: [NFC] Add llvm::StaticVector ADT.

Reverse include order of ArrayRef.h and StaticVector.h in unit test code to address pre-merge check failure.

Oct 20 2021, 2:53 PM · Restricted Project, Restricted Project
jplayer-nv added a comment to D112175: [NFC] Add llvm::StaticVector ADT.

could fallible operations ala push_back return an llvm::error?

Oct 20 2021, 2:14 PM · Restricted Project, Restricted Project
jplayer-nv requested review of D112175: [NFC] Add llvm::StaticVector ADT.
Oct 20 2021, 1:05 PM · Restricted Project, Restricted Project

Jan 15 2021

jplayer-nv added a comment to D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

Quick reminder that I don't have commit access, and need someone to commit this patch on my behalf. Thanks!

Jan 15 2021, 9:40 AM · Restricted Project

Jan 14 2021

jplayer-nv updated the diff for D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

Added !defined(__clang__) conditions to static_assert preprocessing. Also added large comment describing the mental gymnastics of the OptionalStorage specialization condition.

Jan 14 2021, 2:58 PM · Restricted Project
jplayer-nv updated the diff for D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

I just triaged the gcc 5.4 build break. It appears that std::is_trivially_copy_constructible<T> instantiates the copy constructor (which is... strange). So we can't query a compile-time property without the compiler forcing instantiation of the deleted copy constructor in this case.

Jan 14 2021, 12:44 PM · Restricted Project
jplayer-nv added a comment to D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

Taking a look at the gcc 5.4 failure now.

Jan 14 2021, 10:00 AM · Restricted Project

Jan 12 2021

jplayer-nv added a comment to D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

@dblaikie, I don't have commit access. Are you the right person to ask to commit this patch on my behalf?

Jan 12 2021, 9:11 AM · Restricted Project

Jan 11 2021

jplayer-nv updated the diff for D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

Properly update the patch to incorporate the separate static_asserts.

Jan 11 2021, 2:56 PM · Restricted Project
jplayer-nv updated the diff for D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

Split conditions into individual static_asserts.

Jan 11 2021, 2:33 PM · Restricted Project

Jan 8 2021

jplayer-nv added a comment to D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

With current change, pre-merge checks pass. I think I've resolved all issues / requests.

Jan 8 2021, 4:42 PM · Restricted Project
jplayer-nv updated the diff for D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

Added preprocessing around static_asserts added to OptionalTests.cpp to only include them in recent windows builds.

Jan 8 2021, 12:09 PM · Restricted Project

Jan 5 2021

jplayer-nv added inline comments to D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.
Jan 5 2021, 1:28 PM · Restricted Project

Jan 4 2021

jplayer-nv added inline comments to D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.
Jan 4 2021, 4:52 PM · Restricted Project
jplayer-nv added inline comments to D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.
Jan 4 2021, 4:10 PM · Restricted Project
jplayer-nv added inline comments to D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.
Jan 4 2021, 12:15 PM · Restricted Project
jplayer-nv updated the diff for D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.
  1. Expanded the check for the trivial specialization of OptionalStorage
  2. Formatted the OptionalStorage template list.
  3. Added a test to ensure that deleting move constructor / assignment will still choose the trivial OptionalStorage specialization.
  4. Added requests static_asserts to validate class properties in Optional testing code.
Jan 4 2021, 12:12 PM · Restricted Project

Dec 18 2020

jplayer-nv added inline comments to D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.
Dec 18 2020, 2:32 PM · Restricted Project
jplayer-nv updated the diff for D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

Clarified comments above deleted volatile copy constructor / assignment in test classes.

Dec 18 2020, 2:32 PM · Restricted Project
jplayer-nv added a comment to D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.

any idea why this only fails for MSVC? It'd be good to understand more why this didn't trip up other builds so we can avoid those sort of divergences in the future, perhaps.

Dec 18 2020, 11:35 AM · Restricted Project
jplayer-nv updated the diff for D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.
  1. Use std::is_trivially_copyable instead of llvm::is_trivially_copyable in Optional storage template specialization logic.
  2. Added test cases to OptionalTest.cpp which will fail compilation (verified on MSVC 16.8.3) if new conditions are absent from Optional storage template specialization logic.
Dec 18 2020, 11:32 AM · Restricted Project

Dec 17 2020

jplayer-nv requested review of D93510: Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable.
Dec 17 2020, 8:56 PM · Restricted Project
jplayer-nv added a comment to D92514: Switch from llvm::is_trivially_copyable to std::is_trivially_copyable.

I spent some time root causing an llvm::Optional build error on MSVC 16.8.3 today related to using std::is_trivially_copyable to set llvm::is_trivially_copyable<T>::value. It looks like the same failure mentioned in this review.

62>C:\src\ocg_llvm\llvm-project\llvm\include\llvm/ADT/BreadthFirstIterator.h(96,12): error C2280: 'llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>> &llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>>::operator =(const llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>> &)': attempting to reference a deleted function (compiling source file C:\src\ocg_llvm\llvm-project\llvm\unittests\ADT\BreadthFirstIteratorTest.cpp)
...

The "trivial" specialization of optional_detail::OptionalStorage assumes that the value type is trivially copy constructible and trivially copy assignable. The specialization is invoked based on a check of is_trivially_copyable, which does not imply both is_trivially_copy_assignable and is_trivially_copy_constructible are true.

According to the spec, a deleted assignment operator does not make is_trivially_copyable false. So I think all these properties need to be checked explicitly in order to specialize OptionalStorage to the "trivial" version:

/// Storage for any type.
template <typename T, bool = std::is_trivially_copy_constructible<T>::value
                          && std::is_trivially_copy_assignable<T>::value>
class OptionalStorage {

Above fixed my build break in MSVC, but I think we might need to explicitly check is_trivially_copy_constructible too since it might be possible the copy constructor is deleted.

All sounds pretty plausible to me - if you want to send a patch to add those checks?

Dec 17 2020, 5:00 PM · Restricted Project
jplayer-nv added a comment to D92514: Switch from llvm::is_trivially_copyable to std::is_trivially_copyable.

I spent some time root causing an llvm::Optional build error on MSVC 16.8.3 today related to using std::is_trivially_copyable to set llvm::is_trivially_copyable<T>::value. It looks like the same failure mentioned in this review.

Dec 17 2020, 4:43 PM · Restricted Project