Add intrusive doubly-linked list container template, IList.
It will be used in the new tsan runtime.
Details
- Reviewers
vitalybuka melver - Commits
- rGf821a55c5e78: tsan: add intrusive doubly-linked list
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/tsan/rtl/tsan_ilist.h | ||
---|---|---|
20 | I thought about if some of it could be made nicer/safer, but don't think it can. In theory, this could be nicer if you only ever needed to add an element to 1 list, which would allow doing template <typename Node> class INode and requiring the containing class Foo to inherit from INode<Foo>. But looking at the rest of tsanv3 changes, it seems you need the ability to add an INode more than once since an element might be added to more than 1 list. While not the prettiest, I think it requires INode* to be part of template arguments of IList, and no other way to do better. It would be nice to document this requirement, because it makes it clearer why you came up with this design. | |
176 | reinterpret_cast<Base*> instead of C-style (Base*) ? |
compiler-rt/lib/tsan/rtl/tsan_ilist.h | ||
---|---|---|
20 | Added an explanatory comment. |
Hi @dvyukov, this patch was causing a failure on clang-ppc64le-rhel bot https://lab.llvm.org/buildbot/#/builders/57/builds/8932 with a unmatching type issue - line 30 EXPECT_EQ(list.Size(), 0); in compiler-rt/lib/tsan/tests/unit/tsan_ilist_test.cpp.
To unblock our bot, I have committed a fix ac2ffdef9cc8d152801ca87d81736fb1dec9cb88. The latest build passed at https://lab.llvm.org/buildbot/#/builders/57/builds/8971 If you want a different fix, feel free to commit a follow-up fix patch. Thanks.
I thought about if some of it could be made nicer/safer, but don't think it can.
In theory, this could be nicer if you only ever needed to add an element to 1 list, which would allow doing template <typename Node> class INode and requiring the containing class Foo to inherit from INode<Foo>.
But looking at the rest of tsanv3 changes, it seems you need the ability to add an INode more than once since an element might be added to more than 1 list.
While not the prettiest, I think it requires INode* to be part of template arguments of IList, and no other way to do better.
It would be nice to document this requirement, because it makes it clearer why you came up with this design.