Fix build with llvm16
This CL fixes building Chromium with swiftshader+LLVM 16.
Currently the build would fail with errors like:
../../third_party/swiftshader/third_party/llvm-16.0/llvm/include/llvm/ADT/SmallVector.h:109:62:
error: missing '#include <bits/stdint-uintn.h>'; 'uint64_t' must be declared before it is used
109 | std::conditional_t<sizeof(T) < 4 && sizeof(void *) >= 8, uint64_t,
| ^
Change-Id: I17659294e8710c8bc3c92365d3f9a2edc4da1032
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/76668
Reviewed-by: Geoff Lang <geofflang@google.com>
Tested-by: Geoff Lang <geofflang@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@google.com>
Commit-Queue: Geoff Lang <geofflang@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/third_party/llvm-16.0/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h b/third_party/llvm-16.0/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
index e41eb06..edbae6e 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
@@ -64,6 +64,7 @@
#include <cassert>
#include <cstddef>
#include <memory>
+#include <type_traits>
namespace llvm {
diff --git a/third_party/llvm-16.0/llvm/include/llvm/ADT/STLFunctionalExtras.h b/third_party/llvm-16.0/llvm/include/llvm/ADT/STLFunctionalExtras.h
index 6d7e5b5..c3c4d92 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/ADT/STLFunctionalExtras.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/ADT/STLFunctionalExtras.h
@@ -20,6 +20,7 @@
#include <type_traits>
#include <utility>
#include <cstdint>
+#include <cstddef>
namespace llvm {
diff --git a/third_party/llvm-16.0/llvm/include/llvm/ADT/SmallVector.h b/third_party/llvm-16.0/llvm/include/llvm/ADT/SmallVector.h
index 98dce89..a52947e 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/ADT/SmallVector.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/ADT/SmallVector.h
@@ -19,6 +19,7 @@
#include <algorithm>
#include <cassert>
#include <cstddef>
+#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <functional>
diff --git a/third_party/llvm-16.0/llvm/include/llvm/ADT/Statistic.h b/third_party/llvm-16.0/llvm/include/llvm/ADT/Statistic.h
index 9475b66..7229a72 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/ADT/Statistic.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/ADT/Statistic.h
@@ -29,6 +29,7 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Compiler.h"
#include <atomic>
+#include <cstdint>
#include <memory>
#include <vector>
diff --git a/third_party/llvm-16.0/llvm/include/llvm/ADT/bit.h b/third_party/llvm-16.0/llvm/include/llvm/ADT/bit.h
index d93023d..3b706f6 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/ADT/bit.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/ADT/bit.h
@@ -16,6 +16,7 @@
#include "llvm/Support/Compiler.h"
#include <cstdint>
+#include <cstddef>
#include <limits>
#include <type_traits>
diff --git a/third_party/llvm-16.0/llvm/include/llvm/IR/ProfileSummary.h b/third_party/llvm-16.0/llvm/include/llvm/IR/ProfileSummary.h
index 4bb6bb8..651d3b3 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/IR/ProfileSummary.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/IR/ProfileSummary.h
@@ -16,6 +16,7 @@
#include <algorithm>
#include <cassert>
#include <cstdint>
+#include <utility>
#include <vector>
namespace llvm {
diff --git a/third_party/llvm-16.0/llvm/include/llvm/Support/Casting.h b/third_party/llvm-16.0/llvm/include/llvm/Support/Casting.h
index 4ff5865..6ce7284 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/Support/Casting.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/Support/Casting.h
@@ -17,6 +17,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/type_traits.h"
#include <cassert>
+#include <cstddef>
#include <memory>
#include <optional>
#include <type_traits>
diff --git a/third_party/llvm-16.0/llvm/include/llvm/Support/NativeFormatting.h b/third_party/llvm-16.0/llvm/include/llvm/Support/NativeFormatting.h
index ab85ae2..1c32297 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/Support/NativeFormatting.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/Support/NativeFormatting.h
@@ -9,6 +9,7 @@
#ifndef LLVM_SUPPORT_NATIVEFORMATTING_H
#define LLVM_SUPPORT_NATIVEFORMATTING_H
+#include <cstddef>
#include <cstdint>
#include <optional>
diff --git a/third_party/llvm-16.0/llvm/include/llvm/Support/thread.h b/third_party/llvm-16.0/llvm/include/llvm/Support/thread.h
index 69c06c0..0376dc1 100644
--- a/third_party/llvm-16.0/llvm/include/llvm/Support/thread.h
+++ b/third_party/llvm-16.0/llvm/include/llvm/Support/thread.h
@@ -17,7 +17,10 @@
#define LLVM_SUPPORT_THREAD_H
#include "llvm/Config/llvm-config.h"
+#include <exception>
+#include <memory>
#include <optional>
+#include <tuple>
#ifdef _WIN32
typedef unsigned long DWORD;
diff --git a/third_party/llvm-16.0/llvm/lib/Support/JSON.cpp b/third_party/llvm-16.0/llvm/lib/Support/JSON.cpp
index 0e7f7bf..19a9d30 100644
--- a/third_party/llvm-16.0/llvm/lib/Support/JSON.cpp
+++ b/third_party/llvm-16.0/llvm/lib/Support/JSON.cpp
@@ -14,6 +14,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/NativeFormatting.h"
#include <cctype>
+#include <cerrno>
#include <optional>
namespace llvm {
diff --git a/third_party/llvm-16.0/llvm/lib/Support/Path.cpp b/third_party/llvm-16.0/llvm/lib/Support/Path.cpp
index 152d902..88e2db2 100644
--- a/third_party/llvm-16.0/llvm/lib/Support/Path.cpp
+++ b/third_party/llvm-16.0/llvm/lib/Support/Path.cpp
@@ -22,6 +22,7 @@
#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h"
#include <cctype>
+#include <cerrno>
#if !defined(_MSC_VER) && !defined(__MINGW32__)
#include <unistd.h>
diff --git a/third_party/llvm-16.0/llvm/lib/Target/ARM/ARMCallLowering.cpp b/third_party/llvm-16.0/llvm/lib/Target/ARM/ARMCallLowering.cpp
index 76b9940..2a7b19b 100644
--- a/third_party/llvm-16.0/llvm/lib/Target/ARM/ARMCallLowering.cpp
+++ b/third_party/llvm-16.0/llvm/lib/Target/ARM/ARMCallLowering.cpp
@@ -161,7 +161,7 @@
std::swap(NewRegs[0], NewRegs[1]);
if (Thunk) {
- *Thunk = [=]() {
+ *Thunk = [=, this]() {
assignValueToReg(NewRegs[0], VA.getLocReg(), VA);
assignValueToReg(NewRegs[1], NextVA.getLocReg(), NextVA);
};
diff --git a/third_party/llvm-16.0/llvm/lib/Target/Mips/MipsCallLowering.cpp b/third_party/llvm-16.0/llvm/lib/Target/Mips/MipsCallLowering.cpp
index 044fad6..93e5795 100644
--- a/third_party/llvm-16.0/llvm/lib/Target/Mips/MipsCallLowering.cpp
+++ b/third_party/llvm-16.0/llvm/lib/Target/Mips/MipsCallLowering.cpp
@@ -279,7 +279,7 @@
// If we can return a thunk, just include the register copies. The unmerge can
// be emitted earlier.
if (Thunk) {
- *Thunk = [=]() {
+ *Thunk = [=, this]() {
MIRBuilder.buildCopy(VALo.getLocReg(), Lo);
MIRBuilder.buildCopy(VAHi.getLocReg(), Hi);
};
diff --git a/third_party/llvm-16.0/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp b/third_party/llvm-16.0/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
index fb7316e..866833e 100644
--- a/third_party/llvm-16.0/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/third_party/llvm-16.0/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -3498,7 +3498,7 @@
bool IsKillSet = false;
- auto clearOperandKillInfo = [=] (MachineInstr &MI, unsigned Index) {
+ auto clearOperandKillInfo = [=, this] (MachineInstr &MI, unsigned Index) {
MachineOperand &MO = MI.getOperand(Index);
if (MO.isReg() && MO.isUse() && MO.isKill() &&
getRegisterInfo().regsOverlap(MO.getReg(), RegNo))
diff --git a/third_party/llvm-16.0/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp b/third_party/llvm-16.0/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
index 7d3a8b4..7156e6f 100644
--- a/third_party/llvm-16.0/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
+++ b/third_party/llvm-16.0/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
@@ -545,7 +545,7 @@
// redundant. Replace with a copy. This doesn't happen directly due
// to code in PPCDAGToDAGISel.cpp, but it can happen when converting
// a load of a double to a vector of 64-bit integers.
- auto isConversionOfLoadAndSplat = [=]() -> bool {
+ auto isConversionOfLoadAndSplat = [=, this]() -> bool {
if (DefOpc != PPC::XVCVDPSXDS && DefOpc != PPC::XVCVDPUXDS)
return false;
Register FeedReg1 =
@@ -657,7 +657,7 @@
if (!DefMI)
break;
unsigned DefOpcode = DefMI->getOpcode();
- auto isConvertOfSplat = [=]() -> bool {
+ auto isConvertOfSplat = [=, this]() -> bool {
if (DefOpcode != PPC::XVCVSPSXWS && DefOpcode != PPC::XVCVSPUXWS)
return false;
Register ConvReg = DefMI->getOperand(1).getReg();
diff --git a/third_party/llvm-16.0/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h b/third_party/llvm-16.0/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
index d0530bd..10b5946 100644
--- a/third_party/llvm-16.0/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
+++ b/third_party/llvm-16.0/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
@@ -13,6 +13,7 @@
#ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
#define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
+#include <cstdint>
#include <memory>
#include <string>