HomePhabricator

ADT: Support copying of IntrusiveRefCntPtr objects

Authored by dblaikie on Dec 3 2020, 3:28 PM.

Description

ADT: Support copying of IntrusiveRefCntPtr objects

This was partially supported but untested for RefCountedBase (the
implicit copy assignment would've been problematic - so delete that) and
unsupported (would not have compiled, because std::atomic is
non-copyable) for ThreadSafeRefCountedBase (implement similar support
to RefCountedBase)

Fix the test that had a copy ctor for the derived object but called
RefCountBase's default ctor from that copy ctor - which meant it wasn't
actually testing RefCountBase's copy semantics.

Details

Committed
dblaikieDec 3 2020, 5:42 PM
Parents
rGc95acf052b53: [mlir][vector][avx512] move avx512 lowering pass into general vector lowering
Branches
Unknown
Tags
Unknown

Event Timeline

njames93 added inline comments.
/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
93

This isn't good, it leaves RefCount in an uninitialized state. Safest to member i it RefCount like in the non thread safe version

dblaikie added inline comments.Dec 3 2020, 6:44 PM
/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
93

Ah, thanks for the catch! Fixed in c98a7ab1b1d647492554872e395b2ae5763fd23e

Seems this technically won't be needed once we're using C++20: https://en.cppreference.com/w/cpp/atomic/atomic/atomic (which may be a ways off anyway - and nice to leave them the same for symmetry later, probably)