4 ms·
I believe that the heavy use of iterators in LLVM was a mistake. The ownership mechanics has never not been a source of extreme confusion and annoying bugs. But
by webkike 10y ago
I believe that the heavy use of iterators in LLVM was a mistake. The ownership mechanics has never not been a source of extreme confusion and annoying bugs. But, it's still a great backend.
- Joky 10y agoCan you elaborate? Especially I don't really see the relation between "iterators" and "ownership".
- DannyBee 10y agoErrr? I'm aware of maybe one iterator invalidation bug in the like the past year, and one or two ownership bugs, mostly in badly written code. On the list of "stuff llvm got wrong", i feel like this wouldn't even make the top hundred.
- webkike 10y agoA large part of writing optimization passes for LLVM consists of figuring out how methods/functions interact with the iterators in terms of validation and ownership. A lot of LLVM is undocumented unfortunately and it's not always clear how they will interact with the iterators. LLVM itself does not suffer from these problems much, but writing opt passes is definitely a huge pain.
- Joky 10y agoMy experience is that LLVM uses of iterator is very coherent with what to expect from C++, and I never had any issue on this aspect. Iterator invalidation is pervasive in the STL containers, and as a C++ programmer you are supposed to know what type of container you're iterating on (in LLVM iterating over a basic block is a linked-list, iterator are not invalidated for instance).