From 5440912f8f80a2c537ba26e340d86c24ea9771df Mon Sep 17 00:00:00 2001 From: akritkbehera Date: Thu, 3 Sep 2026 13:29:06 +0200 Subject: [PATCH] Add a default constructor to llvm::SuccIterator (gcc15) Compiling llvm/lib/IR/Dominators.cpp against the gcc15 libstdc++ fails with stl_iterator.h:182: error: no matching constructor for initialization of 'llvm::SuccIterator' libstdc++ 15 declares std::reverse_iterator's default constructor as noexcept(noexcept(Iterator())). Asking whether a reverse_iterator over succ_iterator is default constructible -- the C++20 semiregular check the ranges code does -- forces that exception specification to be instantiated, and an error inside an exception specification is hard rather than a SFINAE failure, so the concept never gets to simply answer "no" and the build dies. libstdc++ 14 has no such noexcept clause, which is why gcc14 is fine. SuccIterator declares only the begin (InstructionT *) and end (InstructionT *, bool) constructors, so it has no default one. PredIterator, right above it in the same header, already carries "PredIterator() = default;" for this reason. Add SuccIterator() : Inst(nullptr), Idx(0) {}. A null Inst with Idx == 0 is a state the class already supports: the end-iterator constructor uses it for malformed CFGs and index_is_valid() special cases it, so a default constructed iterator behaves like one over a block with no successors. Zero initialising is better than "= default" here, which would leave the pointer and the index indeterminate. There is nothing to backport from upstream -- LLVM main has since folded SuccIterator into Instruction. The hunk rewrites the "// begin iterator" comment rather than being a pure insertion, because bazel's ctx.patch (third_party/repo.bzl applies these with strip = 1) has been seen to silently skip insertion-only hunks, as with the oneDNN fmt_consteval patch. --- third_party/xla/third_party/llvm/gcc15.patch | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/third_party/xla/third_party/llvm/gcc15.patch b/third_party/xla/third_party/llvm/gcc15.patch index 72884f9c1f3feb..9874e42f47feca 100644 --- a/third_party/xla/third_party/llvm/gcc15.patch +++ b/third_party/xla/third_party/llvm/gcc15.patch @@ -27,3 +27,20 @@ index 4a492ee2f..a7ede4bf7 100644 for (auto *Sym : Externals) { SectionRangeSymbolDesc D = F(G, *Sym); +diff --git a/llvm/include/llvm/IR/CFG.h b/llvm/include/llvm/IR/CFG.h +--- a/llvm/include/llvm/IR/CFG.h ++++ b/llvm/include/llvm/IR/CFG.h +@@ -180,7 +180,12 @@ class SuccIterator + }; + + public: +- // begin iterator ++ // default constructed (singular) iterator. libstdc++ 15 gives ++ // std::reverse_iterator's default constructor the exception specification ++ // noexcept(noexcept(Iterator())), which C++20's default_initializable check ++ // instantiates -- a hard error, not a SFINAE failure, without this. ++ SuccIterator() : Inst(nullptr), Idx(0) {} ++ // begin iterator + explicit inline SuccIterator(InstructionT *Inst) : Inst(Inst), Idx(0) {} + // end iterator + inline SuccIterator(InstructionT *Inst, bool) : Inst(Inst) {