C++23 fixes when SWIFTSHADER_LLVM_VERSION=16.0
I was mostly testing llvm-10.0 before, this CL fixes llvm-16.0 too.
There is one follow-up to [1] in llvm-10.0: replace the
s/insert/push_back manual changes I mentioned with actual iterator fixes
in PredIterator and SuccIterator.
[1] https://swiftshader-review.googlesource.com/c/SwiftShader/+/76548
Bug: chromium:388068055
Change-Id: Ia9001f8109b4020c63a85778d7c213f3df4c7e73
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/76589
Reviewed-by: Corentin Wallez <cwallez@google.com>
Commit-Queue: Corentin Wallez <cwallez@google.com>
Tested-by: Corentin Wallez <cwallez@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/third_party/llvm-10.0/llvm/include/llvm/Analysis/LoopInfoImpl.h b/third_party/llvm-10.0/llvm/include/llvm/Analysis/LoopInfoImpl.h
index 3bcb7d0..99f192a 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/Analysis/LoopInfoImpl.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/Analysis/LoopInfoImpl.h
@@ -440,9 +440,9 @@
if (PredBB == L->getHeader())
continue;
// Push all block predecessors on the worklist.
- for (auto it = InvBlockTraits::child_begin(PredBB); it != InvBlockTraits::child_end(PredBB); it++) {
- ReverseCFGWorklist.push_back(*it);
- }
+ ReverseCFGWorklist.insert(ReverseCFGWorklist.end(),
+ InvBlockTraits::child_begin(PredBB),
+ InvBlockTraits::child_end(PredBB));
} else {
// This is a discovered block. Find its outermost discovered loop.
while (LoopT *Parent = Subloop->getParentLoop())
diff --git a/third_party/llvm-10.0/llvm/include/llvm/IR/CFG.h b/third_party/llvm-10.0/llvm/include/llvm/IR/CFG.h
index f9dc638..9046af4 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/IR/CFG.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/IR/CFG.h
@@ -56,9 +56,9 @@
public:
using iterator_category = std::forward_iterator_tag;
- using value_type = Ptr;
+ using value_type = Ptr*;
using difference_type = ptrdiff_t;
- using pointer = Ptr*;
+ using pointer = Ptr**;
using reference = Ptr*;
PredIterator() = default;
@@ -138,7 +138,8 @@
std::random_access_iterator_tag, BlockT, int,
BlockT *, BlockT *> {
public:
- using difference_type = int;
+ using value_type = BlockT *;
+ using difference_type = std::ptrdiff_t;
using pointer = BlockT *;
using reference = BlockT *;
diff --git a/third_party/llvm-10.0/llvm/lib/Analysis/LazyValueInfo.cpp b/third_party/llvm-10.0/llvm/lib/Analysis/LazyValueInfo.cpp
index 3581842..bad2de9 100644
--- a/third_party/llvm-10.0/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/third_party/llvm-10.0/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -345,9 +345,7 @@
if (!changed) continue;
- for (auto it = succ_begin(ToUpdate); it != succ_end(ToUpdate); it++) {
- worklist.push_back(*it);
- }
+ worklist.insert(worklist.end(), succ_begin(ToUpdate), succ_end(ToUpdate));
}
}
diff --git a/third_party/llvm-16.0/llvm/include/llvm/ADT/APFloat.h b/third_party/llvm-16.0/llvm/include/llvm/ADT/APFloat.h
index 3f85a51..780e824 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/ADT/APFloat.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/ADT/APFloat.h
@@ -646,9 +646,9 @@
bool needsCleanup() const { return Floats != nullptr; }
inline APFloat &getFirst();
- inline const APFloat &getFirst();
+ inline const APFloat &getFirst() const;
inline APFloat &getSecond();
- inline const APFloat &getSecond();
+ inline const APFloat &getSecond() const;
opStatus add(const DoubleAPFloat &RHS, roundingMode RM);
opStatus subtract(const DoubleAPFloat &RHS, roundingMode RM);
diff --git a/third_party/llvm-16.0/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h b/third_party/llvm-16.0/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
index ea6ed32..c9263e6 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
@@ -338,7 +338,7 @@
};
template <> struct bind_helper<LLT> {
- static bool bind(const MachineRegisterInfo &MRI, LLT Ty, Register Reg) {
+ static bool bind(const MachineRegisterInfo &MRI, LLT &Ty, Register Reg) {
Ty = MRI.getType(Reg);
if (Ty.isValid())
return true;
@@ -368,7 +368,7 @@
inline bind_ty<Register> m_Reg(Register &R) { return R; }
inline bind_ty<MachineInstr *> m_MInstr(MachineInstr *&MI) { return MI; }
-inline bind_ty<LLT> m_Type(LLT Ty) { return Ty; }
+inline bind_ty<LLT> m_Type(LLT& Ty) { return Ty; }
inline bind_ty<CmpInst::Predicate> m_Pred(CmpInst::Predicate &P) { return P; }
inline operand_type_match m_Pred() { return operand_type_match(); }
diff --git a/third_party/llvm-16.0/llvm/include/llvm/IR/CFG.h b/third_party/llvm-16.0/llvm/include/llvm/IR/CFG.h
index 12ca1b1..a8db93d 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/IR/CFG.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/IR/CFG.h
@@ -42,9 +42,9 @@
class PredIterator {
public:
using iterator_category = std::forward_iterator_tag;
- using value_type = Ptr;
+ using value_type = Ptr *;
using difference_type = std::ptrdiff_t;
- using pointer = Ptr *;
+ using pointer = Ptr **;
using reference = Ptr *;
protected:
@@ -140,7 +140,8 @@
std::random_access_iterator_tag, BlockT, int,
BlockT *, BlockT *> {
public:
- using difference_type = int;
+ using value_type = BlockT *;
+ using difference_type = std::ptrdiff_t;
using pointer = BlockT *;
using reference = BlockT *;
diff --git a/third_party/llvm-16.0/llvm/include/llvm/ProfileData/InstrProfCorrelator.h b/third_party/llvm-16.0/llvm/include/llvm/ProfileData/InstrProfCorrelator.h
index 2e26a21..6e0b761 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/ProfileData/InstrProfCorrelator.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/ProfileData/InstrProfCorrelator.h
@@ -13,6 +13,7 @@
#define LLVM_PROFILEDATA_INSTRPROFCORRELATOR_H
#include "llvm/ADT/DenseSet.h"
+#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"
diff --git a/third_party/llvm-16.0/llvm/include/llvm/Support/ScopedPrinter.h b/third_party/llvm-16.0/llvm/include/llvm/Support/ScopedPrinter.h
index b91acb5..2841344 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/Support/ScopedPrinter.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/Support/ScopedPrinter.h
@@ -519,7 +519,13 @@
startLine() << Label << ": " << hex(Value) << "\n";
}
-struct DelimitedScope;
+struct DelimitedScope {
+ DelimitedScope(ScopedPrinter &W) : W(&W) {}
+ DelimitedScope() : W(nullptr) {}
+ virtual ~DelimitedScope() = default;
+ virtual void setPrinter(ScopedPrinter &W) = 0;
+ ScopedPrinter *W;
+};
class JSONScopedPrinter : public ScopedPrinter {
private:
@@ -798,14 +804,6 @@
}
};
-struct DelimitedScope {
- DelimitedScope(ScopedPrinter &W) : W(&W) {}
- DelimitedScope() : W(nullptr) {}
- virtual ~DelimitedScope() = default;
- virtual void setPrinter(ScopedPrinter &W) = 0;
- ScopedPrinter *W;
-};
-
struct DictScope : DelimitedScope {
explicit DictScope() = default;
explicit DictScope(ScopedPrinter &W) : DelimitedScope(W) { W.objectBegin(); }
diff --git a/third_party/llvm-16.0/llvm/lib/Remarks/BitstreamRemarkParser.cpp b/third_party/llvm-16.0/llvm/lib/Remarks/BitstreamRemarkParser.cpp
index 6dd032f..b8e510a 100644
--- a/third_party/llvm-16.0/llvm/lib/Remarks/BitstreamRemarkParser.cpp
+++ b/third_party/llvm-16.0/llvm/lib/Remarks/BitstreamRemarkParser.cpp
@@ -82,6 +82,15 @@
return Error::success();
}
+BitstreamRemarkParser::BitstreamRemarkParser(StringRef Buf)
+ : RemarkParser(Format::Bitstream), ParserHelper(Buf) {}
+
+BitstreamRemarkParser::BitstreamRemarkParser(StringRef Buf,
+ ParsedStringTable StrTab)
+ : RemarkParser(Format::Bitstream),
+ ParserHelper(Buf),
+ StrTab(std::move(StrTab)) {}
+
BitstreamRemarkParserHelper::BitstreamRemarkParserHelper(
BitstreamCursor &Stream)
: Stream(Stream) {}
diff --git a/third_party/llvm-16.0/llvm/lib/Remarks/BitstreamRemarkParser.h b/third_party/llvm-16.0/llvm/lib/Remarks/BitstreamRemarkParser.h
index fc786fc..08e189c 100644
--- a/third_party/llvm-16.0/llvm/lib/Remarks/BitstreamRemarkParser.h
+++ b/third_party/llvm-16.0/llvm/lib/Remarks/BitstreamRemarkParser.h
@@ -45,13 +45,10 @@
/// Create a parser that expects to find a string table embedded in the
/// stream.
- explicit BitstreamRemarkParser(StringRef Buf)
- : RemarkParser(Format::Bitstream), ParserHelper(Buf) {}
+ explicit BitstreamRemarkParser(StringRef Buf);
/// Create a parser that uses a pre-parsed string table.
- BitstreamRemarkParser(StringRef Buf, ParsedStringTable StrTab)
- : RemarkParser(Format::Bitstream), ParserHelper(Buf),
- StrTab(std::move(StrTab)) {}
+ BitstreamRemarkParser(StringRef Buf, ParsedStringTable StrTab);
Expected<std::unique_ptr<Remark>> next() override;