<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Rolling this out now.<div><br></div><div>-F</div><div><br></div><div><br><div><div>On May 21, 2013, at 1:00 PM, Justin Holewinski <<a href="mailto:justin.holewinski@gmail.com">justin.holewinski@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr">Ubuntu 13.04, GCC 4.7.3, fresh build LLVM w/ CMake + Debug + Clang:<div><br></div><div><div><font face="courier new, monospace">[349/1621] Building CXX object lib/ExecutionEngine/CMakeFiles/LLVMExecutionEngine.dir/RTDyldMemoryManager.cpp.o</font></div><div><font face="courier new, monospace">FAILED: /usr/bin/c++   -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wnon-virtual-dtor -fno-rtti -g -Ilib/ExecutionEngine -I/scratch/jholewinski/llvm/src/llvm/lib/ExecutionEngine -Iinclude -I/scratch/jholewinski/llvm/src/llvm/include    -fno-exceptions -MMD -MT lib/ExecutionEngine/CMakeFiles/LLVMExecutionEngine.dir/RTDyldMemoryManager.cpp.o -MF "lib/ExecutionEngine/CMakeFiles/LLVMExecutionEngine.dir/RTDyldMemoryManager.cpp.o.d" -o lib/ExecutionEngine/CMakeFiles/LLVMExecutionEngine.dir/RTDyldMemoryManager.cpp.o -c /scratch/jholewinski/llvm/src/llvm/lib/ExecutionEngine/RTDyldMemoryManager.cpp</font></div><div><font face="courier new, monospace">/scratch/jholewinski/llvm/src/llvm/lib/ExecutionEngine/RTDyldMemoryManager.cpp: In member function ‘virtual void* llvm::RTDyldMemoryManager::getPointerToNamedFunction(const string&, bool)’:</font></div><div><font face="courier new, monospace">/scratch/jholewinski/llvm/src/llvm/lib/ExecutionEngine/RTDyldMemoryManager.cpp:70:48: error: ‘stat’ was not declared in this scope</font></div><div><font face="courier new, monospace">/scratch/jholewinski/llvm/src/llvm/lib/ExecutionEngine/RTDyldMemoryManager.cpp:71:49: error: ‘fstat’ was not declared in this scope</font></div><div><font face="courier new, monospace">/scratch/jholewinski/llvm/src/llvm/lib/ExecutionEngine/RTDyldMemoryManager.cpp:72:49: error: ‘lstat’ was not declared in this scope</font></div><div><font face="courier new, monospace">/scratch/jholewinski/llvm/src/llvm/lib/ExecutionEngine/RTDyldMemoryManager.cpp:73:50: error: ‘stat64’ was not declared in this scope</font></div><div><font face="courier new, monospace">/scratch/jholewinski/llvm/src/llvm/lib/ExecutionEngine/RTDyldMemoryManager.cpp:74:51: error: ‘fstat64’ was not declared in this scope</font></div><div><font face="courier new, monospace">/scratch/jholewinski/llvm/src/llvm/lib/ExecutionEngine/RTDyldMemoryManager.cpp:75:51: error: ‘lstat64’ was not declared in this scope</font></div><div><font face="courier new, monospace">/scratch/jholewinski/llvm/src/llvm/lib/ExecutionEngine/RTDyldMemoryManager.cpp:77:49: error: ‘mknod’ was not declared in this scope</font></div><div><font face="courier new, monospace">[349/1621] Linking CXX static library lib/libLLVMAnalysis.a</font></div><div><font face="courier new, monospace">ninja: build stopped: subcommand failed.</font></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 21, 2013 at 3:56 PM, Filip Pizlo<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:fpizlo@apple.com" target="_blank">fpizlo@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Author: fpizlo<br>Date: Tue May 21 14:56:00 2013<br>New Revision: 182407<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=182407&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=182407&view=rev</a><br>Log:<br>Put RTDyldMemoryManager into its own file, and make it linked into<br>libExecutionEngine. Move method implementations that aren't specific to<br>allocation out of SectionMemoryManager and into RTDyldMemoryManager.<br><br>This is in preparation for exposing RTDyldMemoryManager through the C<br>API.<br><br><br>Added:<br>   <span class="Apple-converted-space"> </span>llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h<br>   <span class="Apple-converted-space"> </span>llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp<br>Modified:<br>   <span class="Apple-converted-space"> </span>llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h<br>   <span class="Apple-converted-space"> </span>llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h<br>   <span class="Apple-converted-space"> </span>llvm/trunk/lib/ExecutionEngine/CMakeLists.txt<br>   <span class="Apple-converted-space"> </span>llvm/trunk/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp<br>   <span class="Apple-converted-space"> </span>llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp<br><br>Added: llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h?rev=182407&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h?rev=182407&view=auto</a><br>==============================================================================<br>--- llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h (added)<br>+++ llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h Tue May 21 14:56:00 2013<br>@@ -0,0 +1,76 @@<br>+//===-- RTDyldMemoryManager.cpp - Memory manager for MC-JIT -----*- C++ -*-===//<br>+//<br>+//                     The LLVM Compiler Infrastructure<br>+//<br>+// This file is distributed under the University of Illinois Open Source<br>+// License. See LICENSE.TXT for details.<br>+//<br>+//===----------------------------------------------------------------------===//<br>+//<br>+// Interface of the runtime dynamic memory manager base class.<br>+//<br>+//===----------------------------------------------------------------------===//<br>+<br>+#ifndef LLVM_EXECUTIONENGINE_RT_DYLD_MEMORY_MANAGER_H<br>+#define LLVM_EXECUTIONENGINE_RT_DYLD_MEMORY_MANAGER_H<br>+<br>+#include "llvm/ADT/StringRef.h"<br>+#include "llvm/Support/CBindingWrapping.h"<br>+#include "llvm/Support/Memory.h"<br>+#include "llvm-c/ExecutionEngine.h"<br>+<br>+namespace llvm {<br>+<br>+// RuntimeDyld clients often want to handle the memory management of<br>+// what gets placed where. For JIT clients, this is the subset of<br>+// JITMemoryManager required for dynamic loading of binaries.<br>+//<br>+// FIXME: As the RuntimeDyld fills out, additional routines will be needed<br>+//        for the varying types of objects to be allocated.<br>+class RTDyldMemoryManager {<br>+  RTDyldMemoryManager(const RTDyldMemoryManager&) LLVM_DELETED_FUNCTION;<br>+  void operator=(const RTDyldMemoryManager&) LLVM_DELETED_FUNCTION;<br>+public:<br>+  RTDyldMemoryManager() {}<br>+  virtual ~RTDyldMemoryManager();<br>+<br>+  /// Allocate a memory block of (at least) the given size suitable for<br>+  /// executable code. The SectionID is a unique identifier assigned by the JIT<br>+  /// engine, and optionally recorded by the memory manager to access a loaded<br>+  /// section.<br>+  virtual uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,<br>+                                       unsigned SectionID) = 0;<br>+<br>+  /// Allocate a memory block of (at least) the given size suitable for data.<br>+  /// The SectionID is a unique identifier assigned by the JIT engine, and<br>+  /// optionally recorded by the memory manager to access a loaded section.<br>+  virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,<br>+                                       unsigned SectionID, bool IsReadOnly) = 0;<br>+<br>+  /// Register the EH frames with the runtime so that c++ exceptions work.<br>+  virtual void registerEHFrames(StringRef SectionData);<br>+<br>+  /// This method returns the address of the specified function. As such it is<br>+  /// only useful for resolving library symbols, not code generated symbols.<br>+  ///<br>+  /// If \p AbortOnFailure is false and no function with the given name is<br>+  /// found, this function returns a null pointer. Otherwise, it prints a<br>+  /// message to stderr and aborts.<br>+  virtual void *getPointerToNamedFunction(const std::string &Name,<br>+                                          bool AbortOnFailure = true);<br>+<br>+  /// This method is called when object loading is complete and section page<br>+  /// permissions can be applied.  It is up to the memory manager implementation<br>+  /// to decide whether or not to act on this method.  The memory manager will<br>+  /// typically allocate all sections as read-write and then apply specific<br>+  /// permissions when this method is called.  Code sections cannot be executed<br>+  /// until this function has been called.  In addition, any cache coherency<br>+  /// operations needed to reliably use the memory are also performed.<br>+  ///<br>+  /// Returns true if an error occurred, false otherwise.<br>+  virtual bool finalizeMemory(std::string *ErrMsg = 0) = 0;<br>+};<br>+<br>+} // namespace llvm<br>+<br>+#endif // LLVM_EXECUTIONENGINE_RT_DYLD_MEMORY_MANAGER_H<br><br>Modified: llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h?rev=182407&r1=182406&r2=182407&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h?rev=182407&r1=182406&r2=182407&view=diff</a><br>==============================================================================<br>--- llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h (original)<br>+++ llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h Tue May 21 14:56:00 2013<br>@@ -16,6 +16,7 @@<br><br> #include "llvm/ADT/StringRef.h"<br> #include "llvm/ExecutionEngine/ObjectBuffer.h"<br>+#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"<br> #include "llvm/Support/Memory.h"<br><br> namespace llvm {<br>@@ -23,58 +24,6 @@ namespace llvm {<br> class RuntimeDyldImpl;<br> class ObjectImage;<br><br>-// RuntimeDyld clients often want to handle the memory management of<br>-// what gets placed where. For JIT clients, this is the subset of<br>-// JITMemoryManager required for dynamic loading of binaries.<br>-//<br>-// FIXME: As the RuntimeDyld fills out, additional routines will be needed<br>-//        for the varying types of objects to be allocated.<br>-class RTDyldMemoryManager {<br>-  RTDyldMemoryManager(const RTDyldMemoryManager&) LLVM_DELETED_FUNCTION;<br>-  void operator=(const RTDyldMemoryManager&) LLVM_DELETED_FUNCTION;<br>-public:<br>-  RTDyldMemoryManager() {}<br>-  virtual ~RTDyldMemoryManager();<br>-<br>-  /// Allocate a memory block of (at least) the given size suitable for<br>-  /// executable code. The SectionID is a unique identifier assigned by the JIT<br>-  /// engine, and optionally recorded by the memory manager to access a loaded<br>-  /// section.<br>-  virtual uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,<br>-                                       unsigned SectionID) = 0;<br>-<br>-  /// Allocate a memory block of (at least) the given size suitable for data.<br>-  /// The SectionID is a unique identifier assigned by the JIT engine, and<br>-  /// optionally recorded by the memory manager to access a loaded section.<br>-  virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,<br>-                                       unsigned SectionID, bool IsReadOnly) = 0;<br>-<br>-  /// This method returns the address of the specified function. As such it is<br>-  /// only useful for resolving library symbols, not code generated symbols.<br>-  ///<br>-  /// If AbortOnFailure is false and no function with the given name is<br>-  /// found, this function returns a null pointer. Otherwise, it prints a<br>-  /// message to stderr and aborts.<br>-  virtual void *getPointerToNamedFunction(const std::string &Name,<br>-                                          bool AbortOnFailure = true) = 0;<br>-<br>-  /// This method is called when object loading is complete and section page<br>-  /// permissions can be applied.  It is up to the memory manager implementation<br>-  /// to decide whether or not to act on this method.  The memory manager will<br>-  /// typically allocate all sections as read-write and then apply specific<br>-  /// permissions when this method is called.  Code sections cannot be executed<br>-  /// until this function has been called.  In addition, any cache coherency<br>-  /// operations needed to reliably use the memory are also performed.<br>-  ///<br>-  /// Returns true if an error occurred, false otherwise.<br>-  virtual bool finalizeMemory(std::string *ErrMsg = 0) = 0;<br>-<br>-  /// Register the EH frames with the runtime so that c++ exceptions work. The<br>-  /// default implementation does nothing. Look at SectionMemoryManager for one<br>-  /// that uses __register_frame.<br>-  virtual void registerEHFrames(StringRef SectionData);<br>-};<br>-<br> class RuntimeDyld {<br>   RuntimeDyld(const RuntimeDyld &) LLVM_DELETED_FUNCTION;<br>   void operator=(const RuntimeDyld &) LLVM_DELETED_FUNCTION;<br><br>Modified: llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h?rev=182407&r1=182406&r2=182407&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h?rev=182407&r1=182406&r2=182407&view=diff</a><br>==============================================================================<br>--- llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h (original)<br>+++ llvm/trunk/include/llvm/ExecutionEngine/SectionMemoryManager.h Tue May 21 14:56:00 2013<br>@@ -73,17 +73,6 @@ public:<br>   /// \returns true if an error occurred, false otherwise.<br>   virtual bool finalizeMemory(std::string *ErrMsg = 0);<br><br>-  void registerEHFrames(StringRef SectionData);<br>-<br>-  /// This method returns the address of the specified function. As such it is<br>-  /// only useful for resolving library symbols, not code generated symbols.<br>-  ///<br>-  /// If \p AbortOnFailure is false and no function with the given name is<br>-  /// found, this function returns a null pointer. Otherwise, it prints a<br>-  /// message to stderr and aborts.<br>-  virtual void *getPointerToNamedFunction(const std::string &Name,<br>-                                          bool AbortOnFailure = true);<br>-<br>   /// \brief Invalidate instruction cache for code sections.<br>   ///<br>   /// Some platforms with separate data cache and instruction cache require<br><br>Modified: llvm/trunk/lib/ExecutionEngine/CMakeLists.txt<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/CMakeLists.txt?rev=182407&r1=182406&r2=182407&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/CMakeLists.txt?rev=182407&r1=182406&r2=182407&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/ExecutionEngine/CMakeLists.txt (original)<br>+++ llvm/trunk/lib/ExecutionEngine/CMakeLists.txt Tue May 21 14:56:00 2013<br>@@ -3,6 +3,7 @@<br> add_llvm_library(LLVMExecutionEngine<br>   ExecutionEngine.cpp<br>   ExecutionEngineBindings.cpp<br>+  RTDyldMemoryManager.cpp<br>   TargetSelect.cpp<br>   )<br><br><br>Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp?rev=182407&r1=182406&r2=182407&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp?rev=182407&r1=182406&r2=182407&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp (original)<br>+++ llvm/trunk/lib/ExecutionEngine/MCJIT/SectionMemoryManager.cpp Tue May 21 14:56:00 2013<br>@@ -14,7 +14,6 @@<br><br> #include "llvm/Config/config.h"<br> #include "llvm/ExecutionEngine/SectionMemoryManager.h"<br>-#include "llvm/Support/DynamicLibrary.h"<br> #include "llvm/Support/MathExtras.h"<br><br> #ifdef __linux__<br>@@ -146,38 +145,6 @@ bool SectionMemoryManager::finalizeMemor<br>   return false;<br> }<br><br>-// Determine whether we can register EH tables.<br>-#if (defined(__GNUC__) && !defined(__ARM_EABI__) && \<br>-     !defined(__USING_SJLJ_EXCEPTIONS__))<br>-#define HAVE_EHTABLE_SUPPORT 1<br>-#else<br>-#define HAVE_EHTABLE_SUPPORT 0<br>-#endif<br>-<br>-#if HAVE_EHTABLE_SUPPORT<br>-extern "C" void __register_frame(void*);<br>-<br>-static const char *processFDE(const char *Entry) {<br>-  const char *P = Entry;<br>-  uint32_t Length = *((uint32_t*)P);<br>-  P += 4;<br>-  uint32_t Offset = *((uint32_t*)P);<br>-  if (Offset != 0)<br>-    __register_frame((void*)Entry);<br>-  return P + Length;<br>-}<br>-#endif<br>-<br>-void SectionMemoryManager::registerEHFrames(StringRef SectionData) {<br>-#if HAVE_EHTABLE_SUPPORT<br>-  const char *P = SectionData.data();<br>-  const char *End = SectionData.data() + SectionData.size();<br>-  do  {<br>-    P = processFDE(P);<br>-  } while(P != End);<br>-#endif<br>-}<br>-<br> error_code SectionMemoryManager::applyMemoryGroupPermissions(MemoryGroup &MemGroup,<br>                                                             <span class="Apple-converted-space"> </span>unsigned Permissions) {<br><br>@@ -199,57 +166,6 @@ void SectionMemoryManager::invalidateIns<br>                                             CodeMem.AllocatedMem[i].size());<br> }<br><br>-static int jit_noop() {<br>-  return 0;<br>-}<br>-<br>-void *SectionMemoryManager::getPointerToNamedFunction(const std::string &Name,<br>-                                                       bool AbortOnFailure) {<br>-#if defined(__linux__)<br>-  //===--------------------------------------------------------------------===//<br>-  // Function stubs that are invoked instead of certain library calls<br>-  //<br>-  // Force the following functions to be linked in to anything that uses the<br>-  // JIT. This is a hack designed to work around the all-too-clever Glibc<br>-  // strategy of making these functions work differently when inlined vs. when<br>-  // not inlined, and hiding their real definitions in a separate archive file<br>-  // that the dynamic linker can't see. For more info, search for<br>-  // 'libc_nonshared.a' on Google, or read<span class="Apple-converted-space"> </span><a href="http://llvm.org/PR274" target="_blank">http://llvm.org/PR274</a>.<br>-  if (Name == "stat") return (void*)(intptr_t)&stat;<br>-  if (Name == "fstat") return (void*)(intptr_t)&fstat;<br>-  if (Name == "lstat") return (void*)(intptr_t)&lstat;<br>-  if (Name == "stat64") return (void*)(intptr_t)&stat64;<br>-  if (Name == "fstat64") return (void*)(intptr_t)&fstat64;<br>-  if (Name == "lstat64") return (void*)(intptr_t)&lstat64;<br>-  if (Name == "atexit") return (void*)(intptr_t)&atexit;<br>-  if (Name == "mknod") return (void*)(intptr_t)&mknod;<br>-#endif // __linux__<br>-<br>-  // We should not invoke parent's ctors/dtors from generated main()!<br>-  // On Mingw and Cygwin, the symbol __main is resolved to<br>-  // callee's(eg. tools/lli) one, to invoke wrong duplicated ctors<br>-  // (and register wrong callee's dtors with atexit(3)).<br>-  // We expect ExecutionEngine::runStaticConstructorsDestructors()<br>-  // is called before ExecutionEngine::runFunctionAsMain() is called.<br>-  if (Name == "__main") return (void*)(intptr_t)&jit_noop;<br>-<br>-  const char *NameStr = Name.c_str();<br>-  void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr);<br>-  if (Ptr) return Ptr;<br>-<br>-  // If it wasn't found and if it starts with an underscore ('_') character,<br>-  // try again without the underscore.<br>-  if (NameStr[0] == '_') {<br>-    Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr+1);<br>-    if (Ptr) return Ptr;<br>-  }<br>-<br>-  if (AbortOnFailure)<br>-    report_fatal_error("Program used external function '" + Name +<br>-                      "' which could not be resolved!");<br>-  return 0;<br>-}<br>-<br> SectionMemoryManager::~SectionMemoryManager() {<br>   for (unsigned i = 0, e = CodeMem.AllocatedMem.size(); i != e; ++i)<br>     sys::Memory::releaseMappedMemory(CodeMem.AllocatedMem[i]);<br><br>Added: llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp?rev=182407&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp?rev=182407&view=auto</a><br>==============================================================================<br>--- llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp (added)<br>+++ llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp Tue May 21 14:56:00 2013<br>@@ -0,0 +1,105 @@<br>+//===-- RTDyldMemoryManager.cpp - Memory manager for MC-JIT -----*- C++ -*-===//<br>+//<br>+//                     The LLVM Compiler Infrastructure<br>+//<br>+// This file is distributed under the University of Illinois Open Source<br>+// License. See LICENSE.TXT for details.<br>+//<br>+//===----------------------------------------------------------------------===//<br>+//<br>+// Implementation of the runtime dynamic memory manager base class.<br>+//<br>+//===----------------------------------------------------------------------===//<br>+<br>+#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"<br>+#include "llvm/Support/DynamicLibrary.h"<br>+#include "llvm/Support/ErrorHandling.h"<br>+<br>+namespace llvm {<br>+<br>+RTDyldMemoryManager::~RTDyldMemoryManager() {}<br>+<br>+// Determine whether we can register EH tables.<br>+#if (defined(__GNUC__) && !defined(__ARM_EABI__) && \<br>+     !defined(__USING_SJLJ_EXCEPTIONS__))<br>+#define HAVE_EHTABLE_SUPPORT 1<br>+#else<br>+#define HAVE_EHTABLE_SUPPORT 0<br>+#endif<br>+<br>+#if HAVE_EHTABLE_SUPPORT<br>+extern "C" void __register_frame(void*);<br>+<br>+static const char *processFDE(const char *Entry) {<br>+  const char *P = Entry;<br>+  uint32_t Length = *((uint32_t*)P);<br>+  P += 4;<br>+  uint32_t Offset = *((uint32_t*)P);<br>+  if (Offset != 0)<br>+    __register_frame((void*)Entry);<br>+  return P + Length;<br>+}<br>+#endif<br>+<br>+void RTDyldMemoryManager::registerEHFrames(StringRef SectionData) {<br>+#if HAVE_EHTABLE_SUPPORT<br>+  const char *P = SectionData.data();<br>+  const char *End = SectionData.data() + SectionData.size();<br>+  do  {<br>+    P = processFDE(P);<br>+  } while(P != End);<br>+#endif<br>+}<br>+<br>+static int jit_noop() {<br>+  return 0;<br>+}<br>+<br>+void *RTDyldMemoryManager::getPointerToNamedFunction(const std::string &Name,<br>+                                                     bool AbortOnFailure) {<br>+#if defined(__linux__)<br>+  //===--------------------------------------------------------------------===//<br>+  // Function stubs that are invoked instead of certain library calls<br>+  //<br>+  // Force the following functions to be linked in to anything that uses the<br>+  // JIT. This is a hack designed to work around the all-too-clever Glibc<br>+  // strategy of making these functions work differently when inlined vs. when<br>+  // not inlined, and hiding their real definitions in a separate archive file<br>+  // that the dynamic linker can't see. For more info, search for<br>+  // 'libc_nonshared.a' on Google, or read<span class="Apple-converted-space"> </span><a href="http://llvm.org/PR274" target="_blank">http://llvm.org/PR274</a>.<br>+  if (Name == "stat") return (void*)(intptr_t)&stat;<br>+  if (Name == "fstat") return (void*)(intptr_t)&fstat;<br>+  if (Name == "lstat") return (void*)(intptr_t)&lstat;<br>+  if (Name == "stat64") return (void*)(intptr_t)&stat64;<br>+  if (Name == "fstat64") return (void*)(intptr_t)&fstat64;<br>+  if (Name == "lstat64") return (void*)(intptr_t)&lstat64;<br>+  if (Name == "atexit") return (void*)(intptr_t)&atexit;<br>+  if (Name == "mknod") return (void*)(intptr_t)&mknod;<br>+#endif // __linux__<br>+<br>+  // We should not invoke parent's ctors/dtors from generated main()!<br>+  // On Mingw and Cygwin, the symbol __main is resolved to<br>+  // callee's(eg. tools/lli) one, to invoke wrong duplicated ctors<br>+  // (and register wrong callee's dtors with atexit(3)).<br>+  // We expect ExecutionEngine::runStaticConstructorsDestructors()<br>+  // is called before ExecutionEngine::runFunctionAsMain() is called.<br>+  if (Name == "__main") return (void*)(intptr_t)&jit_noop;<br>+<br>+  const char *NameStr = Name.c_str();<br>+  void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr);<br>+  if (Ptr) return Ptr;<br>+<br>+  // If it wasn't found and if it starts with an underscore ('_') character,<br>+  // try again without the underscore.<br>+  if (NameStr[0] == '_') {<br>+    Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr+1);<br>+    if (Ptr) return Ptr;<br>+  }<br>+<br>+  if (AbortOnFailure)<br>+    report_fatal_error("Program used external function '" + Name +<br>+                       "' which could not be resolved!");<br>+  return 0;<br>+}<br>+<br>+} // namespace llvm<br><br>Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=182407&r1=182406&r2=182407&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=182407&r1=182406&r2=182407&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)<br>+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Tue May 21 14:56:00 2013<br>@@ -24,8 +24,6 @@ using namespace llvm;<br> using namespace llvm::object;<br><br> // Empty out-of-line virtual destructor as the key function.<br>-RTDyldMemoryManager::~RTDyldMemoryManager() {}<br>-void RTDyldMemoryManager::registerEHFrames(StringRef SectionData) {}<br> RuntimeDyldImpl::~RuntimeDyldImpl() {}<br><br> namespace llvm {<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></blockquote></div><br><br clear="all"><div><br></div>--<span class="Apple-converted-space"> </span><br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div></div></div></blockquote></div><br></div></body></html>