[llvm] r330093 - NFC: Move ObjectMemoryBuffer to support

Weiming Zhao via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 14 22:17:14 PDT 2018


Author: weimingz
Date: Sat Apr 14 22:17:14 2018
New Revision: 330093

URL: http://llvm.org/viewvc/llvm-project?rev=330093&view=rev
Log:
NFC: Move ObjectMemoryBuffer to support

Summary:
Since the class is used by both MCJIT and LTO, it makes more sense to move it to Support lib.
This is a follow up patch to r329929 and https://reviews.llvm.org/D45244

Reviewers: bkramer, dblaikie

Reviewed By: bkramer

Subscribers: mehdi_amini, eraman, llvm-commits

Differential Revision: https://reviews.llvm.org/D45606

Added:
    llvm/trunk/include/llvm/Support/ObjectMemoryBuffer.h
      - copied, changed from r330092, llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h
Removed:
    llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h
Modified:
    llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileUtils.h
    llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h
    llvm/trunk/lib/LTO/LLVMBuild.txt
    llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
    llvm/trunk/lib/Support/MemoryBuffer.cpp

Removed: llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h?rev=330092&view=auto
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h (removed)
@@ -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<N>,
-  /// 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<char> &&SV)
-    : SV(std::move(SV)), BufferName("<in-memory object>") {
-    init(this->SV.begin(), this->SV.end(), false);
-  }
-
-  /// \brief Construct a named ObjectMemoryBuffer from the given SmallVector
-  ///        r-value and StringRef.
-  ObjectMemoryBuffer(SmallVectorImpl<char> &&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<char, 0> SV;
-  std::string BufferName;
-};
-
-} // namespace llvm
-
-#endif

Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileUtils.h?rev=330093&r1=330092&r2=330093&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileUtils.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileUtils.h Sat Apr 14 22:17:14 2018
@@ -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 <algorithm>

Copied: llvm/trunk/include/llvm/Support/ObjectMemoryBuffer.h (from r330092, llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ObjectMemoryBuffer.h?p2=llvm/trunk/include/llvm/Support/ObjectMemoryBuffer.h&p1=llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h&r1=330092&r2=330093&rev=330093&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h (original)
+++ llvm/trunk/include/llvm/Support/ObjectMemoryBuffer.h Sat Apr 14 22:17:14 2018
@@ -56,6 +56,7 @@ public:
 private:
   SmallVector<char, 0> SV;
   std::string BufferName;
+  void anchor() override;
 };
 
 } // namespace llvm

Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h?rev=330093&r1=330092&r2=330093&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h (original)
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Sat Apr 14 22:17:14 2018
@@ -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;

Modified: llvm/trunk/lib/LTO/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LLVMBuild.txt?rev=330093&r1=330092&r2=330093&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LLVMBuild.txt (original)
+++ llvm/trunk/lib/LTO/LLVMBuild.txt Sat Apr 14 22:17:14 2018
@@ -37,4 +37,3 @@ required_libraries =
  Support
  Target
  TransformUtils
- MCJIT

Modified: llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp?rev=330093&r1=330092&r2=330093&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp Sat Apr 14 22:17:14 2018
@@ -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"

Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=330093&r1=330092&r2=330093&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Sat Apr 14 22:17:14 2018
@@ -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 @@ MemoryBufferRef MemoryBuffer::getMemBuff
 }
 
 void MemoryBuffer::anchor() {}
+void ObjectMemoryBuffer::anchor() {}




More information about the llvm-commits mailing list