<div dir="ltr">I removed the one on ObjectMemoryBuffer again. Making LTO depend on MCJIT isn't right, the right fix would be to move ObjectMemoryBuffer to Support.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Apr 12, 2018 at 1:20 PM Weiming Zhao via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: weimingz<br>
Date: Wed Apr 11 16:09:20 2018<br>
New Revision: 329861<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=329861&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=329861&view=rev</a><br>
Log:<br>
Add missing vtable anchors<br>
<br>
Summary: This patch adds anchor() for MemoryBuffer, raw_fd_ostream, RTDyldMemoryManager, SectionMemoryManager, etc.<br>
<br>
Reviewers: jlebar, eli.friedman, dblaikie<br>
<br>
Reviewed By: dblaikie<br>
<br>
Subscribers: mehdi_amini, mgorny, dblaikie, weimingz, llvm-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D45244" rel="noreferrer" target="_blank">https://reviews.llvm.org/D45244</a><br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h<br>
    llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h<br>
    llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h<br>
    llvm/trunk/include/llvm/Support/MemoryBuffer.h<br>
    llvm/trunk/include/llvm/Support/raw_ostream.h<br>
    llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp<br>
    llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h<br>
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp<br>
    llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp<br>
    llvm/trunk/lib/LTO/LLVMBuild.txt<br>
    llvm/trunk/lib/Support/MemoryBuffer.cpp<br>
    llvm/trunk/lib/Support/raw_ostream.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h (original)<br>
+++ llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h Wed Apr 11 16:09:20 2018<br>
@@ -56,6 +56,7 @@ public:<br>
 private:<br>
   SmallVector<char, 0> SV;<br>
   std::string BufferName;<br>
+  void anchor() override;<br>
 };<br>
<br>
 } // namespace llvm<br>
<br>
Modified: llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h (original)<br>
+++ llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h Wed Apr 11 16:09:20 2018<br>
@@ -47,6 +47,9 @@ public:<br>
   /// newly loaded object.<br>
   virtual void notifyObjectLoaded(ExecutionEngine *EE,<br>
                                   const object::ObjectFile &) {}<br>
+<br>
+private:<br>
+  void anchor() override;<br>
 };<br>
<br>
 // RuntimeDyld clients often want to handle the memory management of<br>
@@ -142,6 +145,9 @@ protected:<br>
   };<br>
   typedef std::vector<EHFrame> EHFrameInfos;<br>
   EHFrameInfos EHFrames;<br>
+<br>
+private:<br>
+  void anchor() override;<br>
 };<br>
<br>
 // Create wrappers for C Binding types (see CBindingWrapping.h).<br>
<br>
Modified: llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h (original)<br>
+++ llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h Wed Apr 11 16:09:20 2018<br>
@@ -182,6 +182,8 @@ private:<br>
   std::error_code applyMemoryGroupPermissions(MemoryGroup &MemGroup,<br>
                                               unsigned Permissions);<br>
<br>
+  void anchor() override;<br>
+<br>
   MemoryGroup CodeMem;<br>
   MemoryGroup RWDataMem;<br>
   MemoryGroup RODataMem;<br>
<br>
Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original)<br>
+++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Wed Apr 11 16:09:20 2018<br>
@@ -148,6 +148,9 @@ public:<br>
   virtual BufferKind getBufferKind() const = 0;<br>
<br>
   MemoryBufferRef getMemBufferRef() const;<br>
+<br>
+private:<br>
+  virtual void anchor();<br>
 };<br>
<br>
 /// This class is an extension of MemoryBuffer, which allows copy-on-write<br>
<br>
Modified: llvm/trunk/include/llvm/Support/raw_ostream.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)<br>
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Wed Apr 11 16:09:20 2018<br>
@@ -329,6 +329,8 @@ private:<br>
   /// Copy data into the buffer. Size must not be greater than the number of<br>
   /// unused bytes in the buffer.<br>
   void copy_to_buffer(const char *Ptr, size_t Size);<br>
+<br>
+  virtual void anchor();<br>
 };<br>
<br>
 /// An abstract base class for streams implementations that also support a<br>
@@ -336,6 +338,7 @@ private:<br>
 /// but needs to patch in a header that needs to know the output size.<br>
 class raw_pwrite_stream : public raw_ostream {<br>
   virtual void pwrite_impl(const char *Ptr, size_t Size, uint64_t Offset) = 0;<br>
+  void anchor() override;<br>
<br>
 public:<br>
   explicit raw_pwrite_stream(bool Unbuffered = false)<br>
@@ -383,6 +386,8 @@ class raw_fd_ostream : public raw_pwrite<br>
   /// Set the flag indicating that an output error has been encountered.<br>
   void error_detected(std::error_code EC) { this->EC = EC; }<br>
<br>
+  void anchor() override;<br>
+<br>
 public:<br>
   /// Open the specified file for writing. If an error occurs, information<br>
   /// about the error is put into EC, and the stream should be immediately<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Wed Apr 11 16:09:20 2018<br>
@@ -28,6 +28,8 @@<br>
<br>
 using namespace llvm;<br>
<br>
+void llvm::ObjectMemoryBuffer::anchor() {}<br>
+<br>
 namespace {<br>
<br>
 static struct RegisterJIT {<br>
@@ -665,3 +667,5 @@ LinkingSymbolResolver::findSymbol(const<br>
     return nullptr;<br>
   return ClientResolver->findSymbol(Name);<br>
 }<br>
+<br>
+void LinkingSymbolResolver::anchor() {}<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Wed Apr 11 16:09:20 2018<br>
@@ -42,6 +42,7 @@ public:<br>
 private:<br>
   MCJIT &ParentEngine;<br>
   std::shared_ptr<LegacyJITSymbolResolver> ClientResolver;<br>
+  void anchor() override;<br>
 };<br>
<br>
 // About Module states: added->loaded->finalized.<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp Wed Apr 11 16:09:20 2018<br>
@@ -298,4 +298,6 @@ void *RTDyldMemoryManager::getPointerToN<br>
   return (void*)Addr;<br>
 }<br>
<br>
+void RTDyldMemoryManager::anchor() {}<br>
+void MCJITMemoryManager::anchor() {}<br>
 } // namespace llvm<br>
<br>
Modified: llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp (original)<br>
+++ llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp Wed Apr 11 16:09:20 2018<br>
@@ -232,6 +232,8 @@ SectionMemoryManager::~SectionMemoryMana<br>
<br>
 SectionMemoryManager::MemoryMapper::~MemoryMapper() {}<br>
<br>
+void SectionMemoryManager::anchor() {}<br>
+<br>
 namespace {<br>
 // Trivial implementation of SectionMemoryManager::MemoryMapper that just calls<br>
 // into sys::Memory.<br>
<br>
Modified: llvm/trunk/lib/LTO/LLVMBuild.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LLVMBuild.txt?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LLVMBuild.txt?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/LTO/LLVMBuild.txt (original)<br>
+++ llvm/trunk/lib/LTO/LLVMBuild.txt Wed Apr 11 16:09:20 2018<br>
@@ -37,3 +37,4 @@ required_libraries =<br>
  Support<br>
  Target<br>
  TransformUtils<br>
+ MCJIT<br>
<br>
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)<br>
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Wed Apr 11 16:09:20 2018<br>
@@ -531,3 +531,5 @@ MemoryBufferRef MemoryBuffer::getMemBuff<br>
   StringRef Identifier = getBufferIdentifier();<br>
   return MemoryBufferRef(Data, Identifier);<br>
 }<br>
+<br>
+void MemoryBuffer::anchor() {}<br>
<br>
Modified: llvm/trunk/lib/Support/raw_ostream.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=329861&r1=329860&r2=329861&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=329861&r1=329860&r2=329861&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)<br>
+++ llvm/trunk/lib/Support/raw_ostream.cpp Wed Apr 11 16:09:20 2018<br>
@@ -474,6 +474,8 @@ raw_ostream &raw_ostream::indent(unsigne<br>
   return *this;<br>
 }<br>
<br>
+void raw_ostream::anchor() {}<br>
+<br>
 //===----------------------------------------------------------------------===//<br>
 //  Formatted Output<br>
 //===----------------------------------------------------------------------===//<br>
@@ -727,6 +729,8 @@ bool raw_fd_ostream::has_colors() const<br>
   return sys::Process::FileDescriptorHasColors(FD);<br>
 }<br>
<br>
+void raw_fd_ostream::anchor() {}<br>
+<br>
 //===----------------------------------------------------------------------===//<br>
 //  outs(), errs(), nulls()<br>
 //===----------------------------------------------------------------------===//<br>
@@ -804,3 +808,5 @@ uint64_t raw_null_ostream::current_pos()<br>
<br>
 void raw_null_ostream::pwrite_impl(const char *Ptr, size_t Size,<br>
                                    uint64_t Offset) {}<br>
+<br>
+void raw_pwrite_stream::anchor() {}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>