pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

llvm-all-in-one: Update to SVN r. 308490



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Wed Jul 19 19:32:57 2017 +0200
Changeset:	02d410accf9bac6d229b6638e58304cc6d10b157

Modified Files:
	llvm-all-in-one/Makefile
	llvm-all-in-one/distinfo
Added Files:
	llvm-all-in-one/patches/patch-include_llvm_ExecutionEngine_Orc_IndirectionUtils.h
	llvm-all-in-one/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h
	llvm-all-in-one/patches/patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp
	llvm-all-in-one/patches/patch-lib_ExecutionEngine_SectionMemoryManager.cpp

Log Message:
llvm-all-in-one: Update to SVN r. 308490

Backport patch from upstream review:
Use sys::Memory::AllocateRWX for JIT code
https://reviews.llvm.org/D35558

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=02d410accf9bac6d229b6638e58304cc6d10b157

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 llvm-all-in-one/Makefile                           |  2 +-
 llvm-all-in-one/distinfo                           |  4 ++
 ...ude_llvm_ExecutionEngine_Orc_IndirectionUtils.h | 52 +++++++++++++++++
 ...lvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h | 65 ++++++++++++++++++++++
 ...patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp | 61 ++++++++++++++++++++
 ...ch-lib_ExecutionEngine_SectionMemoryManager.cpp | 26 +++++++++
 6 files changed, 209 insertions(+), 1 deletion(-)

diffs:
diff --git a/llvm-all-in-one/Makefile b/llvm-all-in-one/Makefile
index 45a6a1850d..62b5441f65 100644
--- a/llvm-all-in-one/Makefile
+++ b/llvm-all-in-one/Makefile
@@ -4,7 +4,7 @@ LLVM_VERSION=	5.0.0
 
 CATEGORIES=	lang devel
 
-LLVM_SVN_REV=		307790
+LLVM_SVN_REV=		308490
 
 SVN_REPOSITORIES=		llvm
 SVN_REPO.llvm=			http://llvm.org/svn/llvm-project/llvm/trunk
diff --git a/llvm-all-in-one/distinfo b/llvm-all-in-one/distinfo
index b743693d4e..2bf18893d1 100644
--- a/llvm-all-in-one/distinfo
+++ b/llvm-all-in-one/distinfo
@@ -12,6 +12,10 @@ Size (libcxx-3.6.2.src.tar.xz) = 944020 bytes
 SHA1 (llvm-3.6.2.src.tar.xz) = 7a00257eb2bc9431e4c77c3a36b033072c54bc7e
 RMD160 (llvm-3.6.2.src.tar.xz) = 521cbc5fe2925ea3c6e90c7a31f752a04045c972
 Size (llvm-3.6.2.src.tar.xz) = 12802380 bytes
+SHA1 (patch-include_llvm_ExecutionEngine_Orc_IndirectionUtils.h) = 7aa55e13e78ed6a4a80520ffada33016ec27a711
+SHA1 (patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h) = e2f96f49e1d5afa1e1cbc3cfc98a81b19f0ce230
+SHA1 (patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp) = b24a57af1c6fea12f0dd252ccfd23ce6945f307d
+SHA1 (patch-lib_ExecutionEngine_SectionMemoryManager.cpp) = f3498378be67171ad4d1a211f6172d5f2f8248f7
 SHA1 (patch-lib_Transforms_Instrumentation_AddressSanitizer.cpp) = 67eee29c4d8525b603e6b7c0a52278bdf3353687
 SHA1 (patch-lib_Transforms_Instrumentation_InstrProfiling.cpp) = 871b474f415d9dc468cc07477101f88d7a20868b
 SHA1 (patch-lib_Transforms_Instrumentation_MemorySanitizer.cpp) = 64fdbb55c77d5f5f73152d2f8daa28adfc428e40
diff --git a/llvm-all-in-one/patches/patch-include_llvm_ExecutionEngine_Orc_IndirectionUtils.h b/llvm-all-in-one/patches/patch-include_llvm_ExecutionEngine_Orc_IndirectionUtils.h
new file mode 100644
index 0000000000..4dffecc3bc
--- /dev/null
+++ b/llvm-all-in-one/patches/patch-include_llvm_ExecutionEngine_Orc_IndirectionUtils.h
@@ -0,0 +1,52 @@
+$NetBSD$
+
+--- include/llvm/ExecutionEngine/Orc/IndirectionUtils.h.orig	2017-07-05 18:41:32.000000000 +0000
++++ include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
+@@ -164,15 +164,16 @@ public:
+   LocalJITCompileCallbackManager(JITTargetAddress ErrorHandlerAddress)
+       : JITCompileCallbackManager(ErrorHandlerAddress) {
+     /// Set up the resolver block.
+-    std::error_code EC;
+-    ResolverBlock = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
+-        TargetT::ResolverCodeSize, nullptr,
+-        sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
+-    assert(!EC && "Failed to allocate resolver block");
++    std::string Err;
++    ResolverBlock = sys::OwningMemoryBlock(
++        sys::Memory::AllocateRWX(TargetT::ResolverCodeSize, nullptr, &Err));
++    if (!ResolverBlock.base())
++      report_fatal_error("Can't allocate enough memory: " + Err);
+ 
+     TargetT::writeResolverCode(static_cast<uint8_t *>(ResolverBlock.base()),
+                                &reenter, this);
+ 
++    std::error_code EC;
+     EC = sys::Memory::protectMappedMemory(ResolverBlock.getMemoryBlock(),
+                                           sys::Memory::MF_READ |
+                                               sys::Memory::MF_EXEC);
+@@ -191,12 +192,11 @@ private:
+   void grow() override {
+     assert(this->AvailableTrampolines.empty() && "Growing prematurely?");
+ 
+-    std::error_code EC;
+-    auto TrampolineBlock =
+-        sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
+-            sys::Process::getPageSize(), nullptr,
+-            sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
+-    assert(!EC && "Failed to allocate trampoline block");
++    std::string Err;
++    auto TrampolineBlock = sys::OwningMemoryBlock(
++        sys::Memory::AllocateRWX(sys::Process::getPageSize(), nullptr, &Err));
++    if (!TrampolineBlock.base())
++      report_fatal_error("Can't allocate enough memory: " + Err);
+ 
+     unsigned NumTrampolines =
+         (sys::Process::getPageSize() - TargetT::PointerSize) /
+@@ -211,6 +211,7 @@ private:
+           static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(
+               TrampolineMem + (I * TargetT::TrampolineSize))));
+ 
++    std::error_code EC;
+     EC = sys::Memory::protectMappedMemory(TrampolineBlock.getMemoryBlock(),
+                                           sys::Memory::MF_READ |
+                                               sys::Memory::MF_EXEC);
diff --git a/llvm-all-in-one/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h b/llvm-all-in-one/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h
new file mode 100644
index 0000000000..e9a6074352
--- /dev/null
+++ b/llvm-all-in-one/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h
@@ -0,0 +1,65 @@
+$NetBSD$
+
+--- include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h.orig	2017-07-05 18:41:32.000000000 +0000
++++ include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h
+@@ -115,11 +115,10 @@ private:
+     }
+ 
+     Error allocate(void *&Addr, size_t Size, uint32_t Align) {
+-      std::error_code EC;
+-      sys::MemoryBlock MB = sys::Memory::allocateMappedMemory(
+-          Size, nullptr, sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC);
+-      if (EC)
+-        return errorCodeToError(EC);
++      std::string Err;
++      sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, &Err);
++      if (!MB.base())
++        report_fatal_error("Can't allocate enough memory: " + Err);
+ 
+       Addr = MB.base();
+       assert(Allocs.find(MB.base()) == Allocs.end() && "Duplicate alloc");
+@@ -277,12 +276,11 @@ private:
+   }
+ 
+   Error handleEmitResolverBlock() {
+-    std::error_code EC;
+-    ResolverBlock = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
+-        TargetT::ResolverCodeSize, nullptr,
+-        sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
+-    if (EC)
+-      return errorCodeToError(EC);
++    std::string Err;
++    ResolverBlock = sys::OwningMemoryBlock(
++        sys::Memory::AllocateRWX(TargetT::ResolverCodeSize, nullptr, &Err));
++    if (!ResolverBlock.base())
++      report_fatal_error("Can't allocate enough memory: " + Err);
+ 
+     TargetT::writeResolverCode(static_cast<uint8_t *>(ResolverBlock.base()),
+                                &reenter, this);
+@@ -293,13 +291,11 @@ private:
+   }
+ 
+   Expected<std::tuple<JITTargetAddress, uint32_t>> handleEmitTrampolineBlock() {
+-    std::error_code EC;
+-    auto TrampolineBlock =
+-        sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
+-            sys::Process::getPageSize(), nullptr,
+-            sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
+-    if (EC)
+-      return errorCodeToError(EC);
++    std::string Err;
++    auto TrampolineBlock = sys::OwningMemoryBlock(
++        sys::Memory::AllocateRWX(sys::Process::getPageSize(), nullptr, &Err));
++    if (!TrampolineBlock.base())
++      report_fatal_error("Can't allocate enough memory: " + Err);
+ 
+     uint32_t NumTrampolines =
+         (sys::Process::getPageSize() - TargetT::PointerSize) /
+@@ -309,6 +305,7 @@ private:
+     TargetT::writeTrampolines(TrampolineMem, ResolverBlock.base(),
+                               NumTrampolines);
+ 
++    std::error_code EC;
+     EC = sys::Memory::protectMappedMemory(TrampolineBlock.getMemoryBlock(),
+                                           sys::Memory::MF_READ |
+                                               sys::Memory::MF_EXEC);
diff --git a/llvm-all-in-one/patches/patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp b/llvm-all-in-one/patches/patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp
new file mode 100644
index 0000000000..af53d8481a
--- /dev/null
+++ b/llvm-all-in-one/patches/patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp
@@ -0,0 +1,61 @@
+$NetBSD$
+
+--- lib/ExecutionEngine/Orc/OrcABISupport.cpp.orig	2017-07-05 18:38:00.000000000 +0000
++++ lib/ExecutionEngine/Orc/OrcABISupport.cpp
+@@ -154,13 +154,11 @@ Error OrcAArch64::emitIndirectStubsBlock
+   unsigned NumStubs = (NumPages * PageSize) / StubSize;
+ 
+   // Allocate memory for stubs and pointers in one call.
+-  std::error_code EC;
+-  auto StubsMem = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
+-      2 * NumPages * PageSize, nullptr,
+-      sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
+-
+-  if (EC)
+-    return errorCodeToError(EC);
++  std::string Err;
++  auto StubsMem = sys::OwningMemoryBlock(
++      sys::Memory::AllocateRWX(2 * NumPages * PageSize, nullptr, &Err));
++  if (!StubsMem.base())
++    report_fatal_error("Can't allocate enough memory: " + Err);
+ 
+   // Create separate MemoryBlocks representing the stubs and pointers.
+   sys::MemoryBlock StubsBlock(StubsMem.base(), NumPages * PageSize);
+@@ -236,13 +234,11 @@ Error OrcX86_64_Base::emitIndirectStubsB
+   unsigned NumStubs = (NumPages * PageSize) / StubSize;
+ 
+   // Allocate memory for stubs and pointers in one call.
+-  std::error_code EC;
+-  auto StubsMem = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
+-      2 * NumPages * PageSize, nullptr,
+-      sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
+-
+-  if (EC)
+-    return errorCodeToError(EC);
++  std::string Err;
++  auto StubsMem = sys::OwningMemoryBlock(
++      sys::Memory::AllocateRWX(2 * NumPages * PageSize, nullptr, &Err));
++  if (!StubsMem.base())
++    report_fatal_error("Can't allocate enough memory: " + Err);
+ 
+   // Create separate MemoryBlocks representing the stubs and pointers.
+   sys::MemoryBlock StubsBlock(StubsMem.base(), NumPages * PageSize);
+@@ -504,13 +500,11 @@ Error OrcI386::emitIndirectStubsBlock(In
+   unsigned NumStubs = (NumPages * PageSize) / StubSize;
+ 
+   // Allocate memory for stubs and pointers in one call.
+-  std::error_code EC;
+-  auto StubsMem = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
+-      2 * NumPages * PageSize, nullptr,
+-      sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
+-
+-  if (EC)
+-    return errorCodeToError(EC);
++  std::string Err;
++  auto StubsMem = sys::OwningMemoryBlock(
++      sys::Memory::AllocateRWX(2 * NumPages * PageSize, nullptr, &Err));
++  if (!StubsMem.base())
++    report_fatal_error("Can't allocate enough memory: " + Err);
+ 
+   // Create separate MemoryBlocks representing the stubs and pointers.
+   sys::MemoryBlock StubsBlock(StubsMem.base(), NumPages * PageSize);
diff --git a/llvm-all-in-one/patches/patch-lib_ExecutionEngine_SectionMemoryManager.cpp b/llvm-all-in-one/patches/patch-lib_ExecutionEngine_SectionMemoryManager.cpp
new file mode 100644
index 0000000000..e3b70848d8
--- /dev/null
+++ b/llvm-all-in-one/patches/patch-lib_ExecutionEngine_SectionMemoryManager.cpp
@@ -0,0 +1,26 @@
+$NetBSD$
+
+--- lib/ExecutionEngine/SectionMemoryManager.cpp.orig	2017-07-05 18:38:00.000000000 +0000
++++ lib/ExecutionEngine/SectionMemoryManager.cpp
+@@ -83,16 +83,11 @@ uint8_t *SectionMemoryManager::allocateS
+   //
+   // FIXME: Initialize the Near member for each memory group to avoid
+   // interleaving.
+-  std::error_code ec;
+-  sys::MemoryBlock MB = sys::Memory::allocateMappedMemory(RequiredSize,
+-                                                          &MemGroup.Near,
+-                                                          sys::Memory::MF_READ |
+-                                                            sys::Memory::MF_WRITE,
+-                                                          ec);
+-  if (ec) {
+-    // FIXME: Add error propagation to the interface.
+-    return nullptr;
+-  }
++  std::string Err;
++  sys::MemoryBlock MB =
++      sys::Memory::AllocateRWX(RequiredSize, &MemGroup.Near, &Err);
++  if (!MB.base())
++    report_fatal_error("Can't allocate enough memory: " + Err);
+ 
+   // Save this address as the basis for our next request
+   MemGroup.Near = MB;


Home | Main Index | Thread Index | Old Index