Update prebuilt Clang to r365631c1 from Android.
The version we had was segfaulting.
Bug: 132420445
Change-Id: Icb45a6fe0b4e2166f7895e669df1157cec9fb4e0
diff --git a/linux-x64/clang/include/llvm/DebugInfo/GSYM/FileEntry.h b/linux-x64/clang/include/llvm/DebugInfo/GSYM/FileEntry.h
new file mode 100644
index 0000000..228b4ef
--- /dev/null
+++ b/linux-x64/clang/include/llvm/DebugInfo/GSYM/FileEntry.h
@@ -0,0 +1,68 @@
+//===- FileEntry.h ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H
+#define LLVM_DEBUGINFO_GSYM_FILEENTRY_H
+
+#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/Hashing.h"
+#include <functional>
+#include <stdint.h>
+#include <utility>
+
+namespace llvm {
+namespace gsym {
+
+/// Files in GSYM are contained in FileEntry structs where we split the
+/// directory and basename into two different strings in the string
+/// table. This allows paths to shared commont directory and filename
+/// strings and saves space.
+struct FileEntry {
+
+ /// Offsets in the string table.
+ /// @{
+ uint32_t Dir = 0;
+ uint32_t Base = 0;
+ /// @}
+
+ FileEntry() = default;
+ FileEntry(uint32_t D, uint32_t B) : Dir(D), Base(B) {}
+
+ // Implement operator== so that FileEntry can be used as key in
+ // unordered containers.
+ bool operator==(const FileEntry &RHS) const {
+ return Base == RHS.Base && Dir == RHS.Dir;
+ };
+ bool operator!=(const FileEntry &RHS) const {
+ return Base != RHS.Base || Dir != RHS.Dir;
+ };
+};
+
+} // namespace gsym
+
+template <> struct DenseMapInfo<gsym::FileEntry> {
+ static inline gsym::FileEntry getEmptyKey() {
+ uint32_t key = DenseMapInfo<uint32_t>::getEmptyKey();
+ return gsym::FileEntry(key, key);
+ }
+ static inline gsym::FileEntry getTombstoneKey() {
+ uint32_t key = DenseMapInfo<uint32_t>::getTombstoneKey();
+ return gsym::FileEntry(key, key);
+ }
+ static unsigned getHashValue(const gsym::FileEntry &Val) {
+ return llvm::hash_combine(DenseMapInfo<uint32_t>::getHashValue(Val.Dir),
+ DenseMapInfo<uint32_t>::getHashValue(Val.Base));
+ }
+ static bool isEqual(const gsym::FileEntry &LHS, const gsym::FileEntry &RHS) {
+ return LHS == RHS;
+ }
+};
+
+} // namespace llvm
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H
diff --git a/linux-x64/clang/include/llvm/DebugInfo/GSYM/FunctionInfo.h b/linux-x64/clang/include/llvm/DebugInfo/GSYM/FunctionInfo.h
new file mode 100644
index 0000000..eedb1e6
--- /dev/null
+++ b/linux-x64/clang/include/llvm/DebugInfo/GSYM/FunctionInfo.h
@@ -0,0 +1,107 @@
+//===- FunctionInfo.h -------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H
+#define LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H
+
+#include "llvm/DebugInfo/GSYM/InlineInfo.h"
+#include "llvm/DebugInfo/GSYM/LineEntry.h"
+#include "llvm/DebugInfo/GSYM/Range.h"
+#include "llvm/DebugInfo/GSYM/StringTable.h"
+#include <tuple>
+#include <vector>
+
+namespace llvm {
+class raw_ostream;
+namespace gsym {
+
+/// Function information in GSYM files encodes information for one
+/// contiguous address range. The name of the function is encoded as
+/// a string table offset and allows multiple functions with the same
+/// name to share the name string in the string table. Line tables are
+/// stored in a sorted vector of gsym::LineEntry objects and are split
+/// into line tables for each function. If a function has a discontiguous
+/// range, it will be split into two gsym::FunctionInfo objects. If the
+/// function has inline functions, the information will be encoded in
+/// the "Inline" member, see gsym::InlineInfo for more information.
+struct FunctionInfo {
+ AddressRange Range;
+ uint32_t Name; ///< String table offset in the string table.
+ std::vector<gsym::LineEntry> Lines;
+ InlineInfo Inline;
+
+ FunctionInfo(uint64_t Addr = 0, uint64_t Size = 0, uint32_t N = 0)
+ : Range(Addr, Addr + Size), Name(N) {}
+
+ bool hasRichInfo() const {
+ /// Returns whether we have something else than range and name. When
+ /// converting information from a symbol table and from debug info, we
+ /// might end up with multiple FunctionInfo objects for the same range
+ /// and we need to be able to tell which one is the better object to use.
+ return !Lines.empty() || Inline.isValid();
+ }
+
+ bool isValid() const {
+ /// Address and size can be zero and there can be no line entries for a
+ /// symbol so the only indication this entry is valid is if the name is
+ /// not zero. This can happen when extracting information from symbol
+ /// tables that do not encode symbol sizes. In that case only the
+ /// address and name will be filled in.
+ return Name != 0;
+ }
+
+ uint64_t startAddress() const { return Range.Start; }
+ uint64_t endAddress() const { return Range.End; }
+ uint64_t size() const { return Range.size(); }
+ void setStartAddress(uint64_t Addr) { Range.Start = Addr; }
+ void setEndAddress(uint64_t Addr) { Range.End = Addr; }
+ void setSize(uint64_t Size) { Range.End = Range.Start + Size; }
+
+ void clear() {
+ Range = {0, 0};
+ Name = 0;
+ Lines.clear();
+ Inline.clear();
+ }
+};
+
+inline bool operator==(const FunctionInfo &LHS, const FunctionInfo &RHS) {
+ return LHS.Range == RHS.Range && LHS.Name == RHS.Name &&
+ LHS.Lines == RHS.Lines && LHS.Inline == RHS.Inline;
+}
+inline bool operator!=(const FunctionInfo &LHS, const FunctionInfo &RHS) {
+ return !(LHS == RHS);
+}
+/// This sorting will order things consistently by address range first, but then
+/// followed by inlining being valid and line tables. We might end up with a
+/// FunctionInfo from debug info that will have the same range as one from the
+/// symbol table, but we want to quickly be able to sort and use the best version
+/// when creating the final GSYM file.
+inline bool operator<(const FunctionInfo &LHS, const FunctionInfo &RHS) {
+ // First sort by address range
+ if (LHS.Range != RHS.Range)
+ return LHS.Range < RHS.Range;
+
+ // Then sort by inline
+ if (LHS.Inline.isValid() != RHS.Inline.isValid())
+ return RHS.Inline.isValid();
+
+ // If the number of lines is the same, then compare line table entries
+ if (LHS.Lines.size() == RHS.Lines.size())
+ return LHS.Lines < RHS.Lines;
+ // Then sort by number of line table entries (more is better)
+ return LHS.Lines.size() < RHS.Lines.size();
+}
+
+raw_ostream &operator<<(raw_ostream &OS, const FunctionInfo &R);
+
+} // namespace gsym
+} // namespace llvm
+
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H
diff --git a/linux-x64/clang/include/llvm/DebugInfo/GSYM/InlineInfo.h b/linux-x64/clang/include/llvm/DebugInfo/GSYM/InlineInfo.h
new file mode 100644
index 0000000..2224306
--- /dev/null
+++ b/linux-x64/clang/include/llvm/DebugInfo/GSYM/InlineInfo.h
@@ -0,0 +1,78 @@
+//===- InlineInfo.h ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H
+#define LLVM_DEBUGINFO_GSYM_INLINEINFO_H
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/DebugInfo/GSYM/Range.h"
+#include <stdint.h>
+#include <vector>
+
+
+namespace llvm {
+class raw_ostream;
+
+namespace gsym {
+
+/// Inline information stores the name of the inline function along with
+/// an array of address ranges. It also stores the call file and call line
+/// that called this inline function. This allows us to unwind inline call
+/// stacks back to the inline or concrete function that called this
+/// function. Inlined functions contained in this function are stored in the
+/// "Children" variable. All address ranges must be sorted and all address
+/// ranges of all children must be contained in the ranges of this function.
+/// Any clients that encode information will need to ensure the ranges are
+/// all contined correctly or lookups could fail. Add ranges in these objects
+/// must be contained in the top level FunctionInfo address ranges as well.
+struct InlineInfo {
+
+ uint32_t Name; ///< String table offset in the string table.
+ uint32_t CallFile; ///< 1 based file index in the file table.
+ uint32_t CallLine; ///< Source line number.
+ AddressRanges Ranges;
+ std::vector<InlineInfo> Children;
+ InlineInfo() : Name(0), CallFile(0), CallLine(0) {}
+ void clear() {
+ Name = 0;
+ CallFile = 0;
+ CallLine = 0;
+ Ranges.clear();
+ Children.clear();
+ }
+ bool isValid() const { return !Ranges.empty(); }
+
+ using InlineArray = std::vector<const InlineInfo *>;
+
+ /// Lookup an address in the InlineInfo object
+ ///
+ /// This function is used to symbolicate an inline call stack and can
+ /// turn one address in the program into one or more inline call stacks
+ /// and have the stack trace show the original call site from
+ /// non-inlined code.
+ ///
+ /// \param Addr the address to lookup
+ ///
+ /// \returns optional vector of InlineInfo objects that describe the
+ /// inline call stack for a given address, false otherwise.
+ llvm::Optional<InlineArray> getInlineStack(uint64_t Addr) const;
+};
+
+inline bool operator==(const InlineInfo &LHS, const InlineInfo &RHS) {
+ return LHS.Name == RHS.Name && LHS.CallFile == RHS.CallFile &&
+ LHS.CallLine == RHS.CallLine && LHS.Ranges == RHS.Ranges &&
+ LHS.Children == RHS.Children;
+}
+
+raw_ostream &operator<<(raw_ostream &OS, const InlineInfo &FI);
+
+} // namespace gsym
+} // namespace llvm
+
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H
diff --git a/linux-x64/clang/include/llvm/DebugInfo/GSYM/LineEntry.h b/linux-x64/clang/include/llvm/DebugInfo/GSYM/LineEntry.h
new file mode 100644
index 0000000..6b93809
--- /dev/null
+++ b/linux-x64/clang/include/llvm/DebugInfo/GSYM/LineEntry.h
@@ -0,0 +1,48 @@
+//===- LineEntry.h ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H
+#define LLVM_DEBUGINFO_GSYM_LINEENTRY_H
+
+#include "llvm/DebugInfo/GSYM/Range.h"
+
+namespace llvm {
+namespace gsym {
+
+/// Line entries are used to encode the line tables in FunctionInfo objects.
+/// They are stored as a sorted vector of these objects and store the
+/// address, file and line of the line table row for a given address. The
+/// size of a line table entry is calculated by looking at the next entry
+/// in the FunctionInfo's vector of entries.
+struct LineEntry {
+ uint64_t Addr; ///< Start address of this line entry.
+ uint32_t File; ///< 1 based index of file in FileTable
+ uint32_t Line; ///< Source line number.
+ LineEntry(uint64_t A = 0, uint32_t F = 0, uint32_t L = 0)
+ : Addr(A), File(F), Line(L) {}
+ bool isValid() { return File != 0; }
+};
+
+inline raw_ostream &operator<<(raw_ostream &OS, const LineEntry &LE) {
+ return OS << "addr=" << HEX64(LE.Addr) << ", file=" << format("%3u", LE.File)
+ << ", line=" << format("%3u", LE.Line);
+}
+
+inline bool operator==(const LineEntry &LHS, const LineEntry &RHS) {
+ return LHS.Addr == RHS.Addr && LHS.File == RHS.File && LHS.Line == RHS.Line;
+}
+inline bool operator!=(const LineEntry &LHS, const LineEntry &RHS) {
+ return !(LHS == RHS);
+}
+inline bool operator<(const LineEntry &LHS, const LineEntry &RHS) {
+ return LHS.Addr < RHS.Addr;
+}
+} // namespace gsym
+} // namespace llvm
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H
diff --git a/linux-x64/clang/include/llvm/DebugInfo/GSYM/Range.h b/linux-x64/clang/include/llvm/DebugInfo/GSYM/Range.h
new file mode 100644
index 0000000..772ff24
--- /dev/null
+++ b/linux-x64/clang/include/llvm/DebugInfo/GSYM/Range.h
@@ -0,0 +1,87 @@
+//===- AddressRange.h -------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_GSYM_RANGE_H
+#define LLVM_DEBUGINFO_GSYM_RANGE_H
+
+#include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
+#include <stdint.h>
+#include <vector>
+
+#define HEX8(v) llvm::format_hex(v, 4)
+#define HEX16(v) llvm::format_hex(v, 6)
+#define HEX32(v) llvm::format_hex(v, 10)
+#define HEX64(v) llvm::format_hex(v, 18)
+
+namespace llvm {
+class raw_ostream;
+
+namespace gsym {
+
+/// A class that represents an address range. The range is specified using
+/// a start and an end address.
+struct AddressRange {
+ uint64_t Start;
+ uint64_t End;
+ AddressRange() : Start(0), End(0) {}
+ AddressRange(uint64_t S, uint64_t E) : Start(S), End(E) {}
+ uint64_t size() const { return End - Start; }
+ bool contains(uint64_t Addr) const { return Start <= Addr && Addr < End; }
+ bool intersects(const AddressRange &R) const {
+ return Start < R.End && R.Start < End;
+ }
+
+ bool operator==(const AddressRange &R) const {
+ return Start == R.Start && End == R.End;
+ }
+ bool operator!=(const AddressRange &R) const {
+ return !(*this == R);
+ }
+ bool operator<(const AddressRange &R) const {
+ return std::make_pair(Start, End) < std::make_pair(R.Start, R.End);
+ }
+};
+
+raw_ostream &operator<<(raw_ostream &OS, const AddressRange &R);
+
+/// The AddressRanges class helps normalize address range collections.
+/// This class keeps a sorted vector of AddressRange objects and can perform
+/// insertions and searches efficiently. The address ranges are always sorted
+/// and never contain any invalid or empty address ranges. This allows us to
+/// emit address ranges into the GSYM file efficiently. Intersecting address
+/// ranges are combined during insertion so that we can emit the most compact
+/// representation for address ranges when writing to disk.
+class AddressRanges {
+protected:
+ using Collection = std::vector<AddressRange>;
+ Collection Ranges;
+public:
+ void clear() { Ranges.clear(); }
+ bool empty() const { return Ranges.empty(); }
+ bool contains(uint64_t Addr) const;
+ void insert(AddressRange Range);
+ size_t size() const { return Ranges.size(); }
+ bool operator==(const AddressRanges &RHS) const {
+ return Ranges == RHS.Ranges;
+ }
+ const AddressRange &operator[](size_t i) const {
+ assert(i < Ranges.size());
+ return Ranges[i];
+ }
+ Collection::const_iterator begin() const { return Ranges.begin(); }
+ Collection::const_iterator end() const { return Ranges.end(); }
+};
+
+raw_ostream &operator<<(raw_ostream &OS, const AddressRanges &AR);
+
+} // namespace gsym
+} // namespace llvm
+
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_RANGE_H
diff --git a/linux-x64/clang/include/llvm/DebugInfo/GSYM/StringTable.h b/linux-x64/clang/include/llvm/DebugInfo/GSYM/StringTable.h
new file mode 100644
index 0000000..0001b8b
--- /dev/null
+++ b/linux-x64/clang/include/llvm/DebugInfo/GSYM/StringTable.h
@@ -0,0 +1,54 @@
+//===- StringTable.h --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_GSYM_STRINGTABLE_H
+#define LLVM_DEBUGINFO_GSYM_STRINGTABLE_H
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/DebugInfo/GSYM/Range.h"
+#include <stdint.h>
+#include <string>
+
+
+namespace llvm {
+namespace gsym {
+
+/// String tables in GSYM files are required to start with an empty
+/// string at offset zero. Strings must be UTF8 NULL terminated strings.
+struct StringTable {
+ StringRef Data;
+ StringTable() : Data() {}
+ StringTable(StringRef D) : Data(D) {}
+ StringRef operator[](size_t Offset) const { return getString(Offset); }
+ StringRef getString(uint32_t Offset) const {
+ if (Offset < Data.size()) {
+ auto End = Data.find('\0', Offset);
+ return Data.substr(Offset, End - Offset);
+ }
+ return StringRef();
+ }
+ void clear() { Data = StringRef(); }
+};
+
+inline raw_ostream &operator<<(raw_ostream &OS, const StringTable &S) {
+ OS << "String table:\n";
+ uint32_t Offset = 0;
+ const size_t Size = S.Data.size();
+ while (Offset < Size) {
+ StringRef Str = S.getString(Offset);
+ OS << HEX32(Offset) << ": \"" << Str << "\"\n";
+ Offset += Str.size() + 1;
+ }
+ return OS;
+}
+
+} // namespace gsym
+} // namespace llvm
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_STRINGTABLE_H