Index: llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h =================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h +++ llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h @@ -1,63 +0,0 @@ -//===- ObjectMemoryBuffer.h - SmallVector-backed MemoryBuffrer -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares a wrapper class to hold the memory into which an -// object will be generated. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_EXECUTIONENGINE_OBJECTMEMORYBUFFER_H -#define LLVM_EXECUTIONENGINE_OBJECTMEMORYBUFFER_H - -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/raw_ostream.h" - -namespace llvm { - -/// \brief SmallVector-backed MemoryBuffer instance. -/// -/// This class enables efficient construction of MemoryBuffers from SmallVector -/// instances. This is useful for MCJIT and Orc, where object files are streamed -/// into SmallVectors, then inspected using ObjectFile (which takes a -/// MemoryBuffer). -class ObjectMemoryBuffer : public MemoryBuffer { -public: - - /// \brief Construct an ObjectMemoryBuffer from the given SmallVector r-value. - /// - /// FIXME: It'd be nice for this to be a non-templated constructor taking a - /// SmallVectorImpl here instead of a templated one taking a SmallVector, - /// but SmallVector's move-construction/assignment currently only take - /// SmallVectors. If/when that is fixed we can simplify this constructor and - /// the following one. - ObjectMemoryBuffer(SmallVectorImpl &&SV) - : SV(std::move(SV)), BufferName("") { - init(this->SV.begin(), this->SV.end(), false); - } - - /// \brief Construct a named ObjectMemoryBuffer from the given SmallVector - /// r-value and StringRef. - ObjectMemoryBuffer(SmallVectorImpl &&SV, StringRef Name) - : SV(std::move(SV)), BufferName(Name) { - init(this->SV.begin(), this->SV.end(), false); - } - - StringRef getBufferIdentifier() const override { return BufferName; } - - BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; } - -private: - SmallVector SV; - std::string BufferName; -}; - -} // namespace llvm - -#endif Index: llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileUtils.h =================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileUtils.h +++ llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileUtils.h @@ -16,13 +16,13 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ExecutionEngine/ObjectCache.h" -#include "llvm/ExecutionEngine/ObjectMemoryBuffer.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/Object/Binary.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/ObjectMemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" #include Index: llvm/trunk/include/llvm/Support/ObjectMemoryBuffer.h =================================================================== --- llvm/trunk/include/llvm/Support/ObjectMemoryBuffer.h +++ llvm/trunk/include/llvm/Support/ObjectMemoryBuffer.h @@ -0,0 +1,64 @@ +//===- ObjectMemoryBuffer.h - SmallVector-backed MemoryBuffrer -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares a wrapper class to hold the memory into which an +// object will be generated. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_EXECUTIONENGINE_OBJECTMEMORYBUFFER_H +#define LLVM_EXECUTIONENGINE_OBJECTMEMORYBUFFER_H + +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/raw_ostream.h" + +namespace llvm { + +/// \brief SmallVector-backed MemoryBuffer instance. +/// +/// This class enables efficient construction of MemoryBuffers from SmallVector +/// instances. This is useful for MCJIT and Orc, where object files are streamed +/// into SmallVectors, then inspected using ObjectFile (which takes a +/// MemoryBuffer). +class ObjectMemoryBuffer : public MemoryBuffer { +public: + + /// \brief Construct an ObjectMemoryBuffer from the given SmallVector r-value. + /// + /// FIXME: It'd be nice for this to be a non-templated constructor taking a + /// SmallVectorImpl here instead of a templated one taking a SmallVector, + /// but SmallVector's move-construction/assignment currently only take + /// SmallVectors. If/when that is fixed we can simplify this constructor and + /// the following one. + ObjectMemoryBuffer(SmallVectorImpl &&SV) + : SV(std::move(SV)), BufferName("") { + init(this->SV.begin(), this->SV.end(), false); + } + + /// \brief Construct a named ObjectMemoryBuffer from the given SmallVector + /// r-value and StringRef. + ObjectMemoryBuffer(SmallVectorImpl &&SV, StringRef Name) + : SV(std::move(SV)), BufferName(Name) { + init(this->SV.begin(), this->SV.end(), false); + } + + StringRef getBufferIdentifier() const override { return BufferName; } + + BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; } + +private: + SmallVector SV; + std::string BufferName; + void anchor() override; +}; + +} // namespace llvm + +#endif Index: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h =================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h @@ -14,10 +14,10 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ObjectCache.h" -#include "llvm/ExecutionEngine/ObjectMemoryBuffer.h" #include "llvm/ExecutionEngine/RTDyldMemoryManager.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/IR/Module.h" +#include "llvm/Support/ObjectMemoryBuffer.h" namespace llvm { class MCJIT; Index: llvm/trunk/lib/LTO/LLVMBuild.txt =================================================================== --- llvm/trunk/lib/LTO/LLVMBuild.txt +++ llvm/trunk/lib/LTO/LLVMBuild.txt @@ -37,4 +37,3 @@ Support Target TransformUtils - MCJIT Index: llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp =================================================================== --- llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp +++ llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp @@ -23,7 +23,6 @@ #include "llvm/Bitcode/BitcodeReader.h" #include "llvm/Bitcode/BitcodeWriter.h" #include "llvm/Bitcode/BitcodeWriterPass.h" -#include "llvm/ExecutionEngine/ObjectMemoryBuffer.h" #include "llvm/IR/DebugInfo.h" #include "llvm/IR/DiagnosticPrinter.h" #include "llvm/IR/LLVMContext.h" @@ -37,6 +36,7 @@ #include "llvm/Support/CachePruning.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Error.h" +#include "llvm/Support/ObjectMemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/SHA1.h" #include "llvm/Support/TargetRegistry.h" Index: llvm/trunk/lib/Support/MemoryBuffer.cpp =================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp +++ llvm/trunk/lib/Support/MemoryBuffer.cpp @@ -18,6 +18,7 @@ #include "llvm/Support/Errno.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/ObjectMemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" #include "llvm/Support/Program.h" @@ -533,3 +534,4 @@ } void MemoryBuffer::anchor() {} +void ObjectMemoryBuffer::anchor() {}