diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/GCOV.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Support/CMakeLists.txt | 3 | ||||
-rw-r--r-- | llvm/lib/Support/DataStream.cpp | 86 | ||||
-rw-r--r-- | llvm/lib/Support/MemoryObject.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/Support/StreamingMemoryObject.cpp | 138 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h | 1 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp | 1 |
8 files changed, 0 insertions, 245 deletions
diff --git a/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp index a9f7f45ee30..3bbcf781e5d 100644 --- a/llvm/lib/IR/GCOV.cpp +++ b/llvm/lib/IR/GCOV.cpp @@ -17,7 +17,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" -#include "llvm/Support/MemoryObject.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt index d8ecfa9b862..5b14c828db0 100644 --- a/llvm/lib/Support/CMakeLists.txt +++ b/llvm/lib/Support/CMakeLists.txt @@ -45,7 +45,6 @@ add_llvm_library(LLVMSupport ConvertUTFWrapper.cpp CrashRecoveryContext.cpp DataExtractor.cpp - DataStream.cpp Debug.cpp DeltaAlgorithm.cpp DAGDeltaAlgorithm.cpp @@ -69,7 +68,6 @@ add_llvm_library(LLVMSupport ManagedStatic.cpp MathExtras.cpp MemoryBuffer.cpp - MemoryObject.cpp MD5.cpp NativeFormatting.cpp Options.cpp @@ -85,7 +83,6 @@ add_llvm_library(LLVMSupport SourceMgr.cpp SpecialCaseList.cpp Statistic.cpp - StreamingMemoryObject.cpp StringExtras.cpp StringMap.cpp StringPool.cpp diff --git a/llvm/lib/Support/DataStream.cpp b/llvm/lib/Support/DataStream.cpp deleted file mode 100644 index 3b10fc5eeca..00000000000 --- a/llvm/lib/Support/DataStream.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===--- llvm/Support/DataStream.cpp - Lazy streamed data -----------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements DataStreamer, which fetches bytes of Data from -// a stream source. It provides support for streaming (lazy reading) of -// bitcode. An example implementation of streaming from a file or stdin -// is included. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/DataStream.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/Program.h" -#include <string> -#include <system_error> -#if !defined(_MSC_VER) && !defined(__MINGW32__) -#include <unistd.h> -#else -#include <io.h> -#endif -using namespace llvm; - -#define DEBUG_TYPE "Data-stream" - -// Interface goals: -// * StreamingMemoryObject doesn't care about complexities like using -// threads/async callbacks to actually overlap download+compile -// * Don't want to duplicate Data in memory -// * Don't need to know total Data len in advance -// Non-goals: -// StreamingMemoryObject already has random access so this interface only does -// in-order streaming (no arbitrary seeking, else we'd have to buffer all the -// Data here in addition to MemoryObject). This also means that if we want -// to be able to to free Data, BitstreamBytes/BitcodeReader will implement it - -STATISTIC(NumStreamFetches, "Number of calls to Data stream fetch"); - -namespace llvm { -DataStreamer::~DataStreamer() {} -} - -namespace { - -// Very simple stream backed by a file. Mostly useful for stdin and debugging; -// actual file access is probably still best done with mmap. -class DataFileStreamer : public DataStreamer { - int Fd; -public: - DataFileStreamer() : Fd(0) {} - ~DataFileStreamer() override { close(Fd); } - size_t GetBytes(unsigned char *buf, size_t len) override { - NumStreamFetches++; - return read(Fd, buf, len); - } - - std::error_code OpenFile(const std::string &Filename) { - if (Filename == "-") { - Fd = 0; - sys::ChangeStdinToBinary(); - return std::error_code(); - } - - return sys::fs::openFileForRead(Filename, Fd); - } -}; - -} - -std::unique_ptr<DataStreamer> -llvm::getDataFileStreamer(const std::string &Filename, std::string *StrError) { - std::unique_ptr<DataFileStreamer> s = make_unique<DataFileStreamer>(); - if (std::error_code e = s->OpenFile(Filename)) { - *StrError = std::string("Could not open ") + Filename + ": " + - e.message() + "\n"; - return nullptr; - } - return std::move(s); -} diff --git a/llvm/lib/Support/MemoryObject.cpp b/llvm/lib/Support/MemoryObject.cpp deleted file mode 100644 index d796acfa90e..00000000000 --- a/llvm/lib/Support/MemoryObject.cpp +++ /dev/null @@ -1,14 +0,0 @@ -//===- MemoryObject.cpp - Abstract memory interface -----------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/MemoryObject.h" -using namespace llvm; - -MemoryObject::~MemoryObject() { -} diff --git a/llvm/lib/Support/StreamingMemoryObject.cpp b/llvm/lib/Support/StreamingMemoryObject.cpp deleted file mode 100644 index fb566179486..00000000000 --- a/llvm/lib/Support/StreamingMemoryObject.cpp +++ /dev/null @@ -1,138 +0,0 @@ -//===- StreamingMemoryObject.cpp - Streamable data interface -------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/StreamingMemoryObject.h" -#include <cassert> -#include <cstddef> -#include <cstring> -using namespace llvm; - -namespace { - -class RawMemoryObject : public MemoryObject { -public: - RawMemoryObject(const unsigned char *Start, const unsigned char *End) : - FirstChar(Start), LastChar(End) { - assert(LastChar >= FirstChar && "Invalid start/end range"); - } - - uint64_t getExtent() const override { - return LastChar - FirstChar; - } - uint64_t readBytes(uint8_t *Buf, uint64_t Size, - uint64_t Address) const override; - const uint8_t *getPointer(uint64_t address, uint64_t size) const override; - bool isValidAddress(uint64_t address) const override { - return validAddress(address); - } - -private: - const uint8_t* const FirstChar; - const uint8_t* const LastChar; - - // These are implemented as inline functions here to avoid multiple virtual - // calls per public function - bool validAddress(uint64_t address) const { - return static_cast<std::ptrdiff_t>(address) < LastChar - FirstChar; - } - - RawMemoryObject(const RawMemoryObject&) = delete; - void operator=(const RawMemoryObject&) = delete; -}; - -uint64_t RawMemoryObject::readBytes(uint8_t *Buf, uint64_t Size, - uint64_t Address) const { - uint64_t BufferSize = LastChar - FirstChar; - if (Address >= BufferSize) - return 0; - - uint64_t End = Address + Size; - if (End > BufferSize) - End = BufferSize; - - assert(static_cast<int64_t>(End - Address) >= 0); - Size = End - Address; - memcpy(Buf, Address + FirstChar, Size); - return Size; -} - -const uint8_t *RawMemoryObject::getPointer(uint64_t address, - uint64_t size) const { - return FirstChar + address; -} -} // anonymous namespace - -namespace llvm { -// If the bitcode has a header, then its size is known, and we don't have to -// block until we actually want to read it. -bool StreamingMemoryObject::isValidAddress(uint64_t address) const { - if (ObjectSize && address < ObjectSize) return true; - return fetchToPos(address); -} - -uint64_t StreamingMemoryObject::getExtent() const { - if (ObjectSize) return ObjectSize; - size_t pos = BytesRead + kChunkSize; - // keep fetching until we run out of bytes - while (fetchToPos(pos)) pos += kChunkSize; - return ObjectSize; -} - -uint64_t StreamingMemoryObject::readBytes(uint8_t *Buf, uint64_t Size, - uint64_t Address) const { - fetchToPos(Address + Size - 1); - // Note: For wrapped bitcode files will set ObjectSize after the - // first call to fetchToPos. In such cases, ObjectSize can be - // smaller than BytesRead. - size_t MaxAddress = - (ObjectSize && ObjectSize < BytesRead) ? ObjectSize : BytesRead; - if (Address >= MaxAddress) - return 0; - - uint64_t End = Address + Size; - if (End > MaxAddress) - End = MaxAddress; - assert(End >= Address); - Size = End - Address; - memcpy(Buf, &Bytes[Address + BytesSkipped], Size); - return Size; -} - -const uint8_t *StreamingMemoryObject::getPointer(uint64_t Address, - uint64_t Size) const { - fetchToPos(Address + Size - 1); - return &Bytes[Address + BytesSkipped]; -} - -bool StreamingMemoryObject::dropLeadingBytes(size_t s) { - if (BytesRead < s) return true; - BytesSkipped = s; - BytesRead -= s; - return false; -} - -void StreamingMemoryObject::setKnownObjectSize(size_t size) { - ObjectSize = size; - Bytes.reserve(size); - if (ObjectSize <= BytesRead) - EOFReached = true; -} - -MemoryObject *getNonStreamedMemoryObject(const unsigned char *Start, - const unsigned char *End) { - return new RawMemoryObject(Start, End); -} - -StreamingMemoryObject::StreamingMemoryObject( - std::unique_ptr<DataStreamer> Streamer) - : Bytes(kChunkSize), Streamer(std::move(Streamer)), BytesRead(0), - BytesSkipped(0), ObjectSize(0), EOFReached(false) { - BytesRead = this->Streamer->GetBytes(&Bytes[0], kChunkSize); -} -} diff --git a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h index e475e505e7d..24e353cf4b9 100644 --- a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h +++ b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.h @@ -18,7 +18,6 @@ namespace llvm { class MCInst; -class MemoryObject; class raw_ostream; class AArch64Disassembler : public MCDisassembler { diff --git a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp index a65522cb14a..92c20365fe0 100644 --- a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp +++ b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp @@ -27,7 +27,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/LEB128.h" -#include "llvm/Support/MemoryObject.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/TargetRegistry.h" diff --git a/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp b/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp index 82ef48e216e..609b650e5d3 100644 --- a/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp +++ b/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp @@ -19,7 +19,6 @@ #include "llvm/MC/MCInst.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Support/MemoryObject.h" #include "llvm/Support/TargetRegistry.h" using namespace llvm; |