[llvm-dev] [broken rL203058] llvm/IR/Metadata.h NamedMDNode iterator broke Mesa with libcxx

Martin Pelikán via llvm-dev llvm-dev at lists.llvm.org
Sun Apr 16 02:54:33 PDT 2017


I've been unable to compile Mesa on my Gentoo box with LLVM and libcxx
for some time, and only now got the time to hunt down the bug:

TL;DR: rL203058 mentions your review which isn't linked in
Phabricator, and it makes NamedMDNode's iterator template<T1,T2> for a
reason unknown to me.  This breaks Mesa which wants to use this
iterator to construct vector<const MDNode *> from {op_begin, op_end}.

If you believe this is Mesa's fault, I'd like to know why (and why
does LLVM bother exporting an std::iterator if people aren't supposed
to use it).

See the following URLs for the interaction:


- C++11 has some special cases for std::vector<> with forward
iterators, which GCC doesn't implement.  This makes Mesa's build
succeed against stdc++ (tested GCC 6.3.0).
- §23.2.3, table 100 wants vector<const MDNode*> to be
EmplaceConstructible from NamedMDNode::const_op_iterator::operator *,
which it is.
- However, libcxx's specialisation of this constructor wants
is_constructible<const MDNode *,
iterator_traits<const_op_iterator>::reference>.  Due to your change in
rL203058, that reference is "T2 = MDNode" because the iterator
inherits from std::iterator<bidi_tag, T2>.  const* type is not
constructible from the value type (I haven't seen in 14882:2011(E) why
it should), so the build fails.

What I want to know is why did you introduce T2 only to pass it into
the parent std::iterator<> class and not anywhere else.  Changing the
inheritance to "T1 = const MDNode*" makes it all work again.

Martin Pelikan

More information about the llvm-dev mailing list