pkgsrc-WIP-changes archive

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

llvm-netbsd: Update to SVN r. 311235



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sat Aug 19 17:42:25 2017 +0200
Changeset:	6962fb038167c6193150d458433710da73d9cba0

Modified Files:
	llvm-netbsd/Makefile.common
	llvm-netbsd/PLIST
	llvm-netbsd/distinfo
Added Files:
	llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_AddressSanitizer.cpp
Removed Files:
	llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_IndirectionUtils.h
	llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetClient.h
	llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetRPCAPI.h
	llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h
	llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_SectionMemoryManager.h
	llvm-netbsd/patches/patch-include_llvm_Support_Memory.h
	llvm-netbsd/patches/patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp
	llvm-netbsd/patches/patch-lib_ExecutionEngine_SectionMemoryManager.cpp
	llvm-netbsd/patches/patch-lib_Support_Unix_Memory.inc
	llvm-netbsd/patches/patch-tools_lli_lli.cpp
	llvm-netbsd/patches/patch-tools_llvm-rtdyld_llvm-rtdyld.cpp

Log Message:
llvm-netbsd: Update to SVN r. 311235

Drop local patches for LLVM JIT, it will be redone again for upstream.

Sync PLIST with upstream.

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=6962fb038167c6193150d458433710da73d9cba0

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

diffstat:
 llvm-netbsd/Makefile.common                        |   2 +-
 llvm-netbsd/PLIST                                  |  10 +-
 llvm-netbsd/distinfo                               |  12 +-
 ...ude_llvm_ExecutionEngine_Orc_IndirectionUtils.h |  41 ---
 ...lvm_ExecutionEngine_Orc_OrcRemoteTargetClient.h |  44 ---
 ...lvm_ExecutionEngine_Orc_OrcRemoteTargetRPCAPI.h |  13 -
 ...lvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h |  90 ------
 ...ude_llvm_ExecutionEngine_SectionMemoryManager.h |  29 --
 .../patches/patch-include_llvm_Support_Memory.h    | 109 -------
 ...patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp |  58 ----
 ...ch-lib_ExecutionEngine_SectionMemoryManager.cpp |  68 -----
 .../patches/patch-lib_Support_Unix_Memory.inc      | 337 ---------------------
 ...Transforms_Instrumentation_AddressSanitizer.cpp |  29 ++
 llvm-netbsd/patches/patch-tools_lli_lli.cpp        |  14 -
 .../patch-tools_llvm-rtdyld_llvm-rtdyld.cpp        |  60 ----
 15 files changed, 36 insertions(+), 880 deletions(-)

diffs:
diff --git a/llvm-netbsd/Makefile.common b/llvm-netbsd/Makefile.common
index d1f844ab17..a7ea9b341d 100644
--- a/llvm-netbsd/Makefile.common
+++ b/llvm-netbsd/Makefile.common
@@ -19,7 +19,7 @@ CATEGORIES=	lang devel
 
 SVN_REPOSITORIES=	llvm
 SVN_REPO.llvm=		http://llvm.org/svn/llvm-project/llvm/trunk
-SVN_REVISION.llvm=	310510
+SVN_REVISION.llvm=	311235
 
 WRKSRC=			${WRKDIR}/llvm
 
diff --git a/llvm-netbsd/PLIST b/llvm-netbsd/PLIST
index 2ffb0631fe..af8b97f0ca 100644
--- a/llvm-netbsd/PLIST
+++ b/llvm-netbsd/PLIST
@@ -171,6 +171,7 @@ include/llvm/Analysis/CallGraph.h
 include/llvm/Analysis/CallGraphSCCPass.h
 include/llvm/Analysis/CallPrinter.h
 include/llvm/Analysis/CaptureTracking.h
+include/llvm/Analysis/CmpInstAnalysis.h
 include/llvm/Analysis/CodeMetrics.h
 include/llvm/Analysis/ConstantFolding.h
 include/llvm/Analysis/DOTGraphTraitsPass.h
@@ -300,7 +301,6 @@ include/llvm/CodeGen/GCMetadataPrinter.h
 include/llvm/CodeGen/GCStrategy.h
 include/llvm/CodeGen/GCs.h
 include/llvm/CodeGen/GlobalISel/CallLowering.h
-include/llvm/CodeGen/GlobalISel/GISelAccessor.h
 include/llvm/CodeGen/GlobalISel/IRTranslator.h
 include/llvm/CodeGen/GlobalISel/InstructionSelect.h
 include/llvm/CodeGen/GlobalISel/InstructionSelector.h
@@ -443,6 +443,7 @@ include/llvm/DebugInfo/CodeView/FunctionId.h
 include/llvm/DebugInfo/CodeView/GUID.h
 include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
 include/llvm/DebugInfo/CodeView/Line.h
+include/llvm/DebugInfo/CodeView/RecordName.h
 include/llvm/DebugInfo/CodeView/RecordSerialization.h
 include/llvm/DebugInfo/CodeView/StringsAndChecksums.h
 include/llvm/DebugInfo/CodeView/SymbolDeserializer.h
@@ -459,7 +460,6 @@ include/llvm/DebugInfo/CodeView/TypeDeserializer.h
 include/llvm/DebugInfo/CodeView/TypeDumpVisitor.h
 include/llvm/DebugInfo/CodeView/TypeIndex.h
 include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h
-include/llvm/DebugInfo/CodeView/TypeName.h
 include/llvm/DebugInfo/CodeView/TypeRecord.h
 include/llvm/DebugInfo/CodeView/TypeRecordBuilder.h
 include/llvm/DebugInfo/CodeView/TypeRecordMapping.h
@@ -528,8 +528,8 @@ include/llvm/DebugInfo/PDB/Native/DbiStream.h
 include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
 include/llvm/DebugInfo/PDB/Native/EnumTables.h
 include/llvm/DebugInfo/PDB/Native/Formatters.h
+include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h
 include/llvm/DebugInfo/PDB/Native/GlobalsStream.h
-include/llvm/DebugInfo/PDB/Native/GlobalsStreamBuilder.h
 include/llvm/DebugInfo/PDB/Native/Hash.h
 include/llvm/DebugInfo/PDB/Native/HashTable.h
 include/llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h
@@ -540,6 +540,8 @@ include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h
 include/llvm/DebugInfo/PDB/Native/NativeBuiltinSymbol.h
 include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
 include/llvm/DebugInfo/PDB/Native/NativeEnumModules.h
+include/llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h
+include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h
 include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
 include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
 include/llvm/DebugInfo/PDB/Native/NativeSession.h
@@ -548,7 +550,6 @@ include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h
 include/llvm/DebugInfo/PDB/Native/PDBStringTable.h
 include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h
 include/llvm/DebugInfo/PDB/Native/PublicsStream.h
-include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h
 include/llvm/DebugInfo/PDB/Native/RawConstants.h
 include/llvm/DebugInfo/PDB/Native/RawError.h
 include/llvm/DebugInfo/PDB/Native/RawTypes.h
@@ -1135,7 +1136,6 @@ include/llvm/Transforms/Utils/BreakCriticalEdges.h
 include/llvm/Transforms/Utils/BuildLibCalls.h
 include/llvm/Transforms/Utils/BypassSlowDivision.h
 include/llvm/Transforms/Utils/Cloning.h
-include/llvm/Transforms/Utils/CmpInstAnalysis.h
 include/llvm/Transforms/Utils/CodeExtractor.h
 include/llvm/Transforms/Utils/CtorUtils.h
 include/llvm/Transforms/Utils/EscapeEnumerator.h
diff --git a/llvm-netbsd/distinfo b/llvm-netbsd/distinfo
index 7b98e4b5cb..d8c2b7ca0a 100644
--- a/llvm-netbsd/distinfo
+++ b/llvm-netbsd/distinfo
@@ -12,14 +12,4 @@ 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) = b529f1363801ab51420d0629ec4caae92c29811f
-SHA1 (patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetClient.h) = e6830599b3037b4e6012684721a645d1cc16a000
-SHA1 (patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetRPCAPI.h) = 4b3a925299bdb52cdfcc0814fe9a07ae18ba3a4d
-SHA1 (patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h) = 38dc1314625e2a5ae015db9f190e8325f40a79fe
-SHA1 (patch-include_llvm_ExecutionEngine_SectionMemoryManager.h) = a5bc1da470dfb85c3a44006e141795b820ac294b
-SHA1 (patch-include_llvm_Support_Memory.h) = 5a94077baf14a94d7cd043beee0be9732260ea3c
-SHA1 (patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp) = 40168426db1821c4a23a45145f13f2ba73525322
-SHA1 (patch-lib_ExecutionEngine_SectionMemoryManager.cpp) = 1d75175cba1b6b3f47bf4b1d8b97a524a1793374
-SHA1 (patch-lib_Support_Unix_Memory.inc) = 02bab22282bf4914918c29b26305424ccd1daec2
-SHA1 (patch-tools_lli_lli.cpp) = 2e5b4b139896e0043f8faad22d864d2f61d55e6f
-SHA1 (patch-tools_llvm-rtdyld_llvm-rtdyld.cpp) = 10eee301995d9c01adb21b27d1baf398a027b3f9
+SHA1 (patch-lib_Transforms_Instrumentation_AddressSanitizer.cpp) = 59ea4dfec39b00a29f69be761310bae545ab11e1
diff --git a/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_IndirectionUtils.h b/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_IndirectionUtils.h
deleted file mode 100644
index cc1213d27f..0000000000
--- a/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_IndirectionUtils.h
+++ /dev/null
@@ -1,41 +0,0 @@
-$NetBSD$
-
---- include/llvm/ExecutionEngine/Orc/IndirectionUtils.h.orig	2017-07-05 18:41:32.000000000 +0000
-+++ include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
-@@ -167,15 +167,14 @@ public:
-     std::error_code EC;
-     ResolverBlock = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
-         TargetT::ResolverCodeSize, nullptr,
--        sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
-+        sys::Memory::ProtectionMode::MF_WRITABLE, EC));
-     assert(!EC && "Failed to allocate resolver block");
- 
-     TargetT::writeResolverCode(static_cast<uint8_t *>(ResolverBlock.base()),
-                                &reenter, this);
- 
-     EC = sys::Memory::protectMappedMemory(ResolverBlock.getMemoryBlock(),
--                                          sys::Memory::MF_READ |
--                                              sys::Memory::MF_EXEC);
-+                                          sys::Memory::ProtectionMode::MF_EXECUTABLE);
-     assert(!EC && "Failed to mprotect resolver block");
-   }
- 
-@@ -195,7 +194,7 @@ private:
-     auto TrampolineBlock =
-         sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
-             sys::Process::getPageSize(), nullptr,
--            sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
-+            sys::Memory::ProtectionMode::MF_WRITABLE, EC));
-     assert(!EC && "Failed to allocate trampoline block");
- 
-     unsigned NumTrampolines =
-@@ -212,8 +211,7 @@ private:
-               TrampolineMem + (I * TargetT::TrampolineSize))));
- 
-     EC = sys::Memory::protectMappedMemory(TrampolineBlock.getMemoryBlock(),
--                                          sys::Memory::MF_READ |
--                                              sys::Memory::MF_EXEC);
-+                                          sys::Memory::ProtectionMode::MF_EXECUTABLE);
-     assert(!EC && "Failed to mprotect trampoline block");
- 
-     TrampolineBlocks.push_back(std::move(TrampolineBlock));
diff --git a/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetClient.h b/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetClient.h
deleted file mode 100644
index 3eea477d6a..0000000000
--- a/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetClient.h
+++ /dev/null
@@ -1,44 +0,0 @@
-$NetBSD$
-
---- include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h.orig	2017-07-05 18:41:32.000000000 +0000
-+++ include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
-@@ -249,8 +249,7 @@ public:
-           DEBUG(dbgs() << "  setting R-X permissions on code block: "
-                        << format("0x%016x", ObjAllocs.RemoteCodeAddr) << "\n");
-           if (auto Err = Client.setProtections(Id, ObjAllocs.RemoteCodeAddr,
--                                               sys::Memory::MF_READ |
--                                                   sys::Memory::MF_EXEC)) {
-+                                                   sys::Memory::ProtectionMode::MF_EXECUTABLE)) {
-             // FIXME: Replace this once finalizeMemory can return an Error.
-             handleAllErrors(std::move(Err), [&](ErrorInfoBase &EIB) {
-               if (ErrMsg) {
-@@ -286,7 +285,7 @@ public:
-                        << format("0x%016x", ObjAllocs.RemoteRODataAddr)
-                        << "\n");
-           if (auto Err = Client.setProtections(Id, ObjAllocs.RemoteRODataAddr,
--                                               sys::Memory::MF_READ)) {
-+                                               sys::Memory::ProtectionMode::MF_READABLE)) {
-             // FIXME: Replace this once finalizeMemory can return an Error.
-             handleAllErrors(std::move(Err), [&](ErrorInfoBase &EIB) {
-               if (ErrMsg) {
-@@ -322,8 +321,7 @@ public:
-                        << format("0x%016x", ObjAllocs.RemoteRWDataAddr)
-                        << "\n");
-           if (auto Err = Client.setProtections(Id, ObjAllocs.RemoteRWDataAddr,
--                                               sys::Memory::MF_READ |
--                                                   sys::Memory::MF_WRITE)) {
-+                                                   sys::Memory::ProtectionMode::MF_WRITABLE)) {
-             // FIXME: Replace this once finalizeMemory can return an Error.
-             handleAllErrors(std::move(Err), [&](ErrorInfoBase &EIB) {
-               if (ErrMsg) {
-@@ -736,8 +734,8 @@ private:
-   }
- 
-   Error setProtections(ResourceIdMgr::ResourceId Id,
--                       JITTargetAddress RemoteSegAddr, unsigned ProtFlags) {
--    return callB<SetProtections>(Id, RemoteSegAddr, ProtFlags);
-+                       JITTargetAddress RemoteSegAddr, sys::Memory::ProtectionMode Mode) {
-+    return callB<SetProtections>(Id, RemoteSegAddr, Mode);
-   }
- 
-   Error writeMem(JITTargetAddress Addr, const char *Src, uint64_t Size) {
diff --git a/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetRPCAPI.h b/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetRPCAPI.h
deleted file mode 100644
index 2539fd5641..0000000000
--- a/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetRPCAPI.h
+++ /dev/null
@@ -1,13 +0,0 @@
-$NetBSD$
-
---- include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h.orig	2017-07-05 18:41:32.000000000 +0000
-+++ include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h
-@@ -239,7 +239,7 @@ public:
-   class SetProtections
-       : public rpc::Function<SetProtections,
-                              void(ResourceIdMgr::ResourceId AllocID,
--                                  JITTargetAddress Dst, uint32_t ProtFlags)> {
-+                                  JITTargetAddress Dst, sys::Memory::ProtectionMode Mode)> {
-   public:
-     static const char *getName() { return "SetProtections"; }
-   };
diff --git a/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h b/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h
deleted file mode 100644
index 5f2a29e7cb..0000000000
--- a/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_Orc_OrcRemoteTargetServer.h
+++ /dev/null
@@ -1,90 +0,0 @@
-$NetBSD$
-
---- include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h.orig	2017-07-05 18:41:32.000000000 +0000
-+++ include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h
-@@ -117,7 +117,7 @@ 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);
-+          Size, nullptr, sys::Memory::ProtectionMode::MF_WRITABLE, EC);
-       if (EC)
-         return errorCodeToError(EC);
- 
-@@ -127,12 +127,12 @@ private:
-       return Error::success();
-     }
- 
--    Error setProtections(void *block, unsigned Flags) {
-+    Error setProtections(void *block, sys::Memory::ProtectionMode Mode) {
-       auto I = Allocs.find(block);
-       if (I == Allocs.end())
-         return errorCodeToError(orcError(OrcErrorCode::RemoteMProtectAddrUnrecognized));
-       return errorCodeToError(
--          sys::Memory::protectMappedMemory(I->second, Flags));
-+          sys::Memory::protectMappedMemory(I->second, Mode));
-     }
- 
-   private:
-@@ -280,7 +280,7 @@ private:
-     std::error_code EC;
-     ResolverBlock = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
-         TargetT::ResolverCodeSize, nullptr,
--        sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
-+        sys::Memory::ProtectionMode::MF_WRITABLE, EC));
-     if (EC)
-       return errorCodeToError(EC);
- 
-@@ -289,7 +289,7 @@ private:
- 
-     return errorCodeToError(sys::Memory::protectMappedMemory(
-         ResolverBlock.getMemoryBlock(),
--        sys::Memory::MF_READ | sys::Memory::MF_EXEC));
-+        sys::Memory::ProtectionMode::MF_EXECUTABLE));
-   }
- 
-   Expected<std::tuple<JITTargetAddress, uint32_t>> handleEmitTrampolineBlock() {
-@@ -297,7 +297,7 @@ private:
-     auto TrampolineBlock =
-         sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
-             sys::Process::getPageSize(), nullptr,
--            sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
-+            sys::Memory::ProtectionMode::MF_WRITABLE, EC));
-     if (EC)
-       return errorCodeToError(EC);
- 
-@@ -310,8 +310,7 @@ private:
-                               NumTrampolines);
- 
-     EC = sys::Memory::protectMappedMemory(TrampolineBlock.getMemoryBlock(),
--                                          sys::Memory::MF_READ |
--                                              sys::Memory::MF_EXEC);
-+                                          sys::Memory::ProtectionMode::MF_EXECUTABLE);
- 
-     TrampolineBlocks.push_back(std::move(TrampolineBlock));
- 
-@@ -389,7 +388,7 @@ private:
-   }
- 
-   Error handleSetProtections(ResourceIdMgr::ResourceId Id,
--                             JITTargetAddress Addr, uint32_t Flags) {
-+                             JITTargetAddress Addr, sys::Memory::ProtectionMode Mode) {
-     auto I = Allocators.find(Id);
-     if (I == Allocators.end())
-       return errorCodeToError(
-@@ -397,10 +396,11 @@ private:
-     auto &Allocator = I->second;
-     void *LocalAddr = reinterpret_cast<void *>(static_cast<uintptr_t>(Addr));
-     DEBUG(dbgs() << "  Allocator " << Id << " set permissions on " << LocalAddr
--                 << " to " << (Flags & sys::Memory::MF_READ ? 'R' : '-')
--                 << (Flags & sys::Memory::MF_WRITE ? 'W' : '-')
--                 << (Flags & sys::Memory::MF_EXEC ? 'X' : '-') << "\n");
--    return Allocator.setProtections(LocalAddr, Flags);
-+                 << " to " << (Mode == sys::Memory::ProtectionMode::MF_READABLE ? "R--" : "")
-+                 << (Mode == sys::Memory::ProtectionMode::MF_WRITABLE ? "RW-" : "")
-+                 << (Mode == sys::Memory::ProtectionMode::MF_READABLE ? "R-X" : "")
-+                 << "\n");
-+    return Allocator.setProtections(LocalAddr, Mode);
-   }
- 
-   Error handleTerminateSession() {
diff --git a/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_SectionMemoryManager.h b/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_SectionMemoryManager.h
deleted file mode 100644
index cf872d6c24..0000000000
--- a/llvm-netbsd/patches/patch-include_llvm_ExecutionEngine_SectionMemoryManager.h
+++ /dev/null
@@ -1,29 +0,0 @@
-$NetBSD$
-
---- include/llvm/ExecutionEngine/SectionMemoryManager.h.orig	2017-07-05 18:41:32.000000000 +0000
-+++ include/llvm/ExecutionEngine/SectionMemoryManager.h
-@@ -76,15 +76,6 @@ public:
-   /// \returns true if an error occurred, false otherwise.
-   bool finalizeMemory(std::string *ErrMsg = nullptr) override;
- 
--  /// \brief Invalidate instruction cache for code sections.
--  ///
--  /// Some platforms with separate data cache and instruction cache require
--  /// explicit cache flush, otherwise JIT code manipulations (like resolved
--  /// relocations) will get to the data cache but not to the instruction cache.
--  ///
--  /// This method is called from finalizeMemory.
--  virtual void invalidateInstructionCache();
--
- private:
-   struct FreeMemBlock {
-     // The actual block of free memory
-@@ -114,7 +105,7 @@ private:
-                            unsigned Alignment);
- 
-   std::error_code applyMemoryGroupPermissions(MemoryGroup &MemGroup,
--                                              unsigned Permissions);
-+                                              sys::Memory::ProtectionMode Mode);
- 
-   MemoryGroup CodeMem;
-   MemoryGroup RWDataMem;
diff --git a/llvm-netbsd/patches/patch-include_llvm_Support_Memory.h b/llvm-netbsd/patches/patch-include_llvm_Support_Memory.h
deleted file mode 100644
index 071cdbae8f..0000000000
--- a/llvm-netbsd/patches/patch-include_llvm_Support_Memory.h
+++ /dev/null
@@ -1,109 +0,0 @@
-$NetBSD$
-
---- include/llvm/Support/Memory.h.orig	2017-07-05 18:41:26.000000000 +0000
-+++ include/llvm/Support/Memory.h
-@@ -45,10 +45,10 @@ namespace sys {
-   /// @brief An abstraction for memory operations.
-   class Memory {
-   public:
--    enum ProtectionFlags {
--      MF_READ  = 0x1000000,
--      MF_WRITE = 0x2000000,
--      MF_EXEC  = 0x4000000
-+    enum class ProtectionMode {
-+      MF_READABLE = 0x1000000,   ///< (R--)
-+      MF_WRITABLE = 0x2000000,   ///< (RW-)
-+      MF_EXECUTABLE  = 0x4000000 ///< (R-X)
-     };
- 
-     /// This method allocates a block of memory that is suitable for loading
-@@ -58,7 +58,7 @@ namespace sys {
-     /// an attempt is made to allocate more memory near the existing block.
-     /// The actual allocated address is not guaranteed to be near the requested
-     /// address.
--    /// \p Flags is used to set the initial protection flags for the block
-+    /// \p Mode is used to set the initial protection mode for the block
-     /// of the memory.
-     /// \p EC [out] returns an object describing any error that occurs.
-     ///
-@@ -77,7 +77,7 @@ namespace sys {
-     /// @brief Allocate mapped memory.
-     static MemoryBlock allocateMappedMemory(size_t NumBytes,
-                                             const MemoryBlock *const NearBlock,
--                                            unsigned Flags,
-+                                            ProtectionMode Mode,
-                                             std::error_code &EC);
- 
-     /// This method releases a block of memory that was allocated with the
-@@ -92,68 +92,18 @@ namespace sys {
-     static std::error_code releaseMappedMemory(MemoryBlock &Block);
- 
-     /// This method sets the protection flags for a block of memory to the
--    /// state specified by /p Flags.  The behavior is not specified if the
-+    /// state specified by /p Mode.  The behavior is not specified if the
-     /// memory was not allocated using the allocateMappedMemory method.
-     /// \p Block describes the memory block to be protected.
--    /// \p Flags specifies the new protection state to be assigned to the block.
-+    /// \p Mode specifies the new protection state to be assigned to the block.
-     /// \p ErrMsg [out] returns a string describing any error that occurred.
-     ///
--    /// If \p Flags is MF_WRITE, the actual behavior varies
--    /// with the operating system (i.e. MF_READ | MF_WRITE on Windows) and the
--    /// target architecture (i.e. MF_WRITE -> MF_READ | MF_WRITE on i386).
--    ///
-     /// \r error_success if the function was successful, or an error_code
-     /// describing the failure if an error occurred.
-     ///
-     /// @brief Set memory protection state.
-     static std::error_code protectMappedMemory(const MemoryBlock &Block,
--                                               unsigned Flags);
--
--    /// This method allocates a block of Read/Write/Execute memory that is
--    /// suitable for executing dynamically generated code (e.g. JIT). An
--    /// attempt to allocate \p NumBytes bytes of virtual memory is made.
--    /// \p NearBlock may point to an existing allocation in which case
--    /// an attempt is made to allocate more memory near the existing block.
--    ///
--    /// On success, this returns a non-null memory block, otherwise it returns
--    /// a null memory block and fills in *ErrMsg.
--    ///
--    /// @brief Allocate Read/Write/Execute memory.
--    static MemoryBlock AllocateRWX(size_t NumBytes,
--                                   const MemoryBlock *NearBlock,
--                                   std::string *ErrMsg = nullptr);
--
--    /// This method releases a block of Read/Write/Execute memory that was
--    /// allocated with the AllocateRWX method. It should not be used to
--    /// release any memory block allocated any other way.
--    ///
--    /// On success, this returns false, otherwise it returns true and fills
--    /// in *ErrMsg.
--    /// @brief Release Read/Write/Execute memory.
--    static bool ReleaseRWX(MemoryBlock &block, std::string *ErrMsg = nullptr);
--
--    /// InvalidateInstructionCache - Before the JIT can run a block of code
--    /// that has been emitted it must invalidate the instruction cache on some
--    /// platforms.
--    static void InvalidateInstructionCache(const void *Addr, size_t Len);
--
--    /// setExecutable - Before the JIT can run a block of code, it has to be
--    /// given read and executable privilege. Return true if it is already r-x
--    /// or the system is able to change its previlege.
--    static bool setExecutable(MemoryBlock &M, std::string *ErrMsg = nullptr);
--
--    /// setWritable - When adding to a block of code, the JIT may need
--    /// to mark a block of code as RW since the protections are on page
--    /// boundaries, and the JIT internal allocations are not page aligned.
--    static bool setWritable(MemoryBlock &M, std::string *ErrMsg = nullptr);
--
--    /// setRangeExecutable - Mark the page containing a range of addresses
--    /// as executable.
--    static bool setRangeExecutable(const void *Addr, size_t Size);
--
--    /// setRangeWritable - Mark the page containing a range of addresses
--    /// as writable.
--    static bool setRangeWritable(const void *Addr, size_t Size);
-+                                               ProtectionMode Mode);
-   };
- 
-   /// Owning version of MemoryBlock.
diff --git a/llvm-netbsd/patches/patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp b/llvm-netbsd/patches/patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp
deleted file mode 100644
index 4379fa11f1..0000000000
--- a/llvm-netbsd/patches/patch-lib_ExecutionEngine_Orc_OrcABISupport.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-$NetBSD$
-
---- lib/ExecutionEngine/Orc/OrcABISupport.cpp.orig	2017-07-05 18:38:00.000000000 +0000
-+++ lib/ExecutionEngine/Orc/OrcABISupport.cpp
-@@ -157,7 +157,7 @@ Error OrcAArch64::emitIndirectStubsBlock
-   std::error_code EC;
-   auto StubsMem = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
-       2 * NumPages * PageSize, nullptr,
--      sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
-+      sys::Memory::ProtectionMode::MF_WRITABLE, EC));
- 
-   if (EC)
-     return errorCodeToError(EC);
-@@ -177,7 +177,7 @@ Error OrcAArch64::emitIndirectStubsBlock
-     Stub[I] = 0xd61f020058000010 | PtrOffsetField;
- 
-   if (auto EC = sys::Memory::protectMappedMemory(
--          StubsBlock, sys::Memory::MF_READ | sys::Memory::MF_EXEC))
-+          StubsBlock, sys::Memory::ProtectionMode::MF_EXECUTABLE))
-     return errorCodeToError(EC);
- 
-   // Initialize all pointers to point at FailureAddress.
-@@ -239,7 +239,7 @@ Error OrcX86_64_Base::emitIndirectStubsB
-   std::error_code EC;
-   auto StubsMem = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
-       2 * NumPages * PageSize, nullptr,
--      sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
-+      sys::Memory::ProtectionMode::MF_WRITABLE, EC));
- 
-   if (EC)
-     return errorCodeToError(EC);
-@@ -258,7 +258,7 @@ Error OrcX86_64_Base::emitIndirectStubsB
-     Stub[I] = 0xF1C40000000025ff | PtrOffsetField;
- 
-   if (auto EC = sys::Memory::protectMappedMemory(
--          StubsBlock, sys::Memory::MF_READ | sys::Memory::MF_EXEC))
-+          StubsBlock, sys::Memory::ProtectionMode::MF_EXECUTABLE))
-     return errorCodeToError(EC);
- 
-   // Initialize all pointers to point at FailureAddress.
-@@ -507,7 +507,7 @@ Error OrcI386::emitIndirectStubsBlock(In
-   std::error_code EC;
-   auto StubsMem = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
-       2 * NumPages * PageSize, nullptr,
--      sys::Memory::MF_READ | sys::Memory::MF_WRITE, EC));
-+      sys::Memory::ProtectionMode::MF_WRITABLE, EC));
- 
-   if (EC)
-     return errorCodeToError(EC);
-@@ -525,7 +525,7 @@ Error OrcI386::emitIndirectStubsBlock(In
-     Stub[I] = 0xF1C40000000025ff | (PtrAddr << 16);
- 
-   if (auto EC = sys::Memory::protectMappedMemory(
--          StubsBlock, sys::Memory::MF_READ | sys::Memory::MF_EXEC))
-+          StubsBlock, sys::Memory::ProtectionMode::MF_EXECUTABLE))
-     return errorCodeToError(EC);
- 
-   // Initialize all pointers to point at FailureAddress.
diff --git a/llvm-netbsd/patches/patch-lib_ExecutionEngine_SectionMemoryManager.cpp b/llvm-netbsd/patches/patch-lib_ExecutionEngine_SectionMemoryManager.cpp
deleted file mode 100644
index db23372409..0000000000
--- a/llvm-netbsd/patches/patch-lib_ExecutionEngine_SectionMemoryManager.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-$NetBSD$
-
---- lib/ExecutionEngine/SectionMemoryManager.cpp.orig	2017-07-05 18:38:00.000000000 +0000
-+++ lib/ExecutionEngine/SectionMemoryManager.cpp
-@@ -86,8 +86,7 @@ uint8_t *SectionMemoryManager::allocateS
-   std::error_code ec;
-   sys::MemoryBlock MB = sys::Memory::allocateMappedMemory(RequiredSize,
-                                                           &MemGroup.Near,
--                                                          sys::Memory::MF_READ |
--                                                            sys::Memory::MF_WRITE,
-+                                                          sys::Memory::ProtectionMode::MF_WRITABLE,
-                                                           ec);
-   if (ec) {
-     // FIXME: Add error propagation to the interface.
-@@ -129,7 +128,7 @@ bool SectionMemoryManager::finalizeMemor
- 
-   // Make code memory executable.
-   ec = applyMemoryGroupPermissions(CodeMem,
--                                   sys::Memory::MF_READ | sys::Memory::MF_EXEC);
-+                                   sys::Memory::ProtectionMode::MF_EXECUTABLE);
-   if (ec) {
-     if (ErrMsg) {
-       *ErrMsg = ec.message();
-@@ -139,7 +138,7 @@ bool SectionMemoryManager::finalizeMemor
- 
-   // Make read-only data memory read-only.
-   ec = applyMemoryGroupPermissions(RODataMem,
--                                   sys::Memory::MF_READ | sys::Memory::MF_EXEC);
-+                                   sys::Memory::ProtectionMode::MF_READABLE);
-   if (ec) {
-     if (ErrMsg) {
-       *ErrMsg = ec.message();
-@@ -149,11 +148,6 @@ bool SectionMemoryManager::finalizeMemor
- 
-   // Read-write data memory already has the correct permissions
- 
--  // Some platforms with separate data cache and instruction cache require
--  // explicit cache flush, otherwise JIT code manipulations (like resolved
--  // relocations) will get to the data cache but not to the instruction cache.
--  invalidateInstructionCache();
--
-   return false;
- }
- 
-@@ -179,9 +173,9 @@ static sys::MemoryBlock trimBlockToPageS
- 
- std::error_code
- SectionMemoryManager::applyMemoryGroupPermissions(MemoryGroup &MemGroup,
--                                                  unsigned Permissions) {
-+                                                  sys::Memory::ProtectionMode Mode) {
-   for (sys::MemoryBlock &MB : MemGroup.PendingMem)
--    if (std::error_code EC = sys::Memory::protectMappedMemory(MB, Permissions))
-+    if (std::error_code EC = sys::Memory::protectMappedMemory(MB, Mode))
-       return EC;
- 
-   MemGroup.PendingMem.clear();
-@@ -203,11 +197,6 @@ SectionMemoryManager::applyMemoryGroupPe
-   return std::error_code();
- }
- 
--void SectionMemoryManager::invalidateInstructionCache() {
--  for (sys::MemoryBlock &Block : CodeMem.PendingMem)
--    sys::Memory::InvalidateInstructionCache(Block.base(), Block.size());
--}
--
- SectionMemoryManager::~SectionMemoryManager() {
-   for (MemoryGroup *Group : {&CodeMem, &RWDataMem, &RODataMem}) {
-     for (sys::MemoryBlock &Block : Group->AllocatedMem)
diff --git a/llvm-netbsd/patches/patch-lib_Support_Unix_Memory.inc b/llvm-netbsd/patches/patch-lib_Support_Unix_Memory.inc
deleted file mode 100644
index 566a1e8aef..0000000000
--- a/llvm-netbsd/patches/patch-lib_Support_Unix_Memory.inc
+++ /dev/null
@@ -1,337 +0,0 @@
-$NetBSD$
-
---- lib/Support/Unix/Memory.inc.orig	2017-07-05 18:38:14.000000000 +0000
-+++ lib/Support/Unix/Memory.inc
-@@ -40,39 +40,64 @@ extern "C" void __clear_cache(void *, vo
- 
- namespace {
- 
--int getPosixProtectionFlags(unsigned Flags) {
--  switch (Flags) {
--  case llvm::sys::Memory::MF_READ:
-+int getPosixProtectionFlags(llvm::sys::Memory::ProtectionMode Mode) {
-+  switch (Mode) {
-+  case llvm::sys::Memory::ProtectionMode::MF_READABLE:
-     return PROT_READ;
--  case llvm::sys::Memory::MF_WRITE:
--    return PROT_WRITE;
--  case llvm::sys::Memory::MF_READ|llvm::sys::Memory::MF_WRITE:
-+  case llvm::sys::Memory::ProtectionMode::MF_WRITABLE:
-     return PROT_READ | PROT_WRITE;
--  case llvm::sys::Memory::MF_READ|llvm::sys::Memory::MF_EXEC:
-+  case llvm::sys::Memory::ProtectionMode::MF_EXECUTABLE:
-     return PROT_READ | PROT_EXEC;
--  case llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_WRITE |
--      llvm::sys::Memory::MF_EXEC:
--    return PROT_READ | PROT_WRITE | PROT_EXEC;
--  case llvm::sys::Memory::MF_EXEC:
--#if defined(__FreeBSD__)
--    // On PowerPC, having an executable page that has no read permission
--    // can have unintended consequences.  The function InvalidateInstruction-
--    // Cache uses instructions dcbf and icbi, both of which are treated by
--    // the processor as loads.  If the page has no read permissions,
--    // executing these instructions will result in a segmentation fault.
--    // Somehow, this problem is not present on Linux, but it does happen
--    // on FreeBSD.
--    return PROT_READ | PROT_EXEC;
--#else
--    return PROT_EXEC;
--#endif
--  default:
--    llvm_unreachable("Illegal memory protection flag specified!");
-   }
-   // Provide a default return value as required by some compilers.
-   return PROT_NONE;
- }
- 
-+/// InvalidateInstructionCache - Before the JIT can run a block of code
-+/// that has been emitted it must invalidate the instruction cache on some
-+/// platforms.
-+void InvalidateInstructionCache(const void *Addr,
-+                                        size_t Len) {
-+
-+// icache invalidation for PPC and ARM.
-+#if defined(__APPLE__)
-+
-+#  if (defined(__POWERPC__) || defined (__ppc__) || \
-+       defined(_POWER) || defined(_ARCH_PPC) || defined(__arm__) || \
-+       defined(__arm64__))
-+  sys_icache_invalidate(const_cast<void *>(Addr), Len);
-+#  endif
-+
-+#else
-+
-+#  if (defined(__POWERPC__) || defined (__ppc__) || \
-+       defined(_POWER) || defined(_ARCH_PPC)) && defined(__GNUC__)
-+  const size_t LineSize = 32;
-+
-+  const intptr_t Mask = ~(LineSize - 1);
-+  const intptr_t StartLine = ((intptr_t) Addr) & Mask;
-+  const intptr_t EndLine = ((intptr_t) Addr + Len + LineSize - 1) & Mask;
-+
-+  for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
-+    asm volatile("dcbf 0, %0" : : "r"(Line));
-+  asm volatile("sync");
-+
-+  for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
-+    asm volatile("icbi 0, %0" : : "r"(Line));
-+  asm volatile("isync");
-+#  elif (defined(__arm__) || defined(__aarch64__) || defined(__mips__)) && \
-+        defined(__GNUC__)
-+  // FIXME: Can we safely always call this for __GNUC__ everywhere?
-+  const char *Start = static_cast<const char *>(Addr);
-+  const char *End = Start + Len;
-+  __clear_cache(const_cast<char *>(Start), const_cast<char *>(End));
-+#  endif
-+
-+#endif  // end apple
-+
-+  llvm::sys::ValgrindDiscardTranslations(Addr, Len);
-+}
-+
- } // anonymous namespace
- 
- namespace llvm {
-@@ -81,7 +106,7 @@ namespace sys {
- MemoryBlock
- Memory::allocateMappedMemory(size_t NumBytes,
-                              const MemoryBlock *const NearBlock,
--                             unsigned PFlags,
-+                             ProtectionMode Mode,
-                              std::error_code &EC) {
-   EC = std::error_code();
-   if (NumBytes == 0)
-@@ -100,7 +125,12 @@ Memory::allocateMappedMemory(size_t NumB
- #endif
-   ; // Ends statement above
- 
--  int Protect = getPosixProtectionFlags(PFlags);
-+  int Protect = getPosixProtectionFlags(Mode);
-+
-+  // Allow swapping memory protection in future on NetBSD with PaX MPROTECT
-+#if defined(__NetBSD__) && defined(PROT_MPROTECT)
-+  Protect |= PROT_MPROTECT(PROT_READ | PROT_WRITE | PROT_EXEC);
-+#endif
- 
-   // Use any near hint and the page size to set a page-aligned starting address
-   uintptr_t Start = NearBlock ? reinterpret_cast<uintptr_t>(NearBlock->base()) +
-@@ -112,7 +142,7 @@ Memory::allocateMappedMemory(size_t NumB
-                       Protect, MMFlags, fd, 0);
-   if (Addr == MAP_FAILED) {
-     if (NearBlock) //Try again without a near hint
--      return allocateMappedMemory(NumBytes, nullptr, PFlags, EC);
-+      return allocateMappedMemory(NumBytes, nullptr, Mode, EC);
- 
-     EC = std::error_code(errno, std::generic_category());
-     return MemoryBlock();
-@@ -122,8 +152,8 @@ Memory::allocateMappedMemory(size_t NumB
-   Result.Address = Addr;
-   Result.Size = NumPages*PageSize;
- 
--  if (PFlags & MF_EXEC)
--    Memory::InvalidateInstructionCache(Result.Address, Result.Size);
-+  if (Mode == ProtectionMode::MF_EXECUTABLE)
-+    InvalidateInstructionCache(Result.Address, Result.Size);
- 
-   return Result;
- }
-@@ -143,15 +173,12 @@ Memory::releaseMappedMemory(MemoryBlock 
- }
- 
- std::error_code
--Memory::protectMappedMemory(const MemoryBlock &M, unsigned Flags) {
-+Memory::protectMappedMemory(const MemoryBlock &M, ProtectionMode Mode) {
-   static const size_t PageSize = Process::getPageSize();
-   if (M.Address == nullptr || M.Size == 0)
-     return std::error_code();
- 
--  if (!Flags)
--    return std::error_code(EINVAL, std::generic_category());
--
--  int Protect = getPosixProtectionFlags(Flags);
-+  int Protect = getPosixProtectionFlags(Mode);
- 
-   uintptr_t Start = alignAddr((uint8_t *)M.Address - PageSize + 1, PageSize);
-   uintptr_t End = alignAddr((uint8_t *)M.Address + M.Size, PageSize);
-@@ -160,179 +187,11 @@ Memory::protectMappedMemory(const Memory
-   if (Result != 0)
-     return std::error_code(errno, std::generic_category());
- 
--  if (Flags & MF_EXEC)
--    Memory::InvalidateInstructionCache(M.Address, M.Size);
-+  if (Mode == ProtectionMode::MF_EXECUTABLE)
-+    InvalidateInstructionCache(M.Address, M.Size);
- 
-   return std::error_code();
- }
- 
--/// AllocateRWX - Allocate a slab of memory with read/write/execute
--/// permissions.  This is typically used for JIT applications where we want
--/// to emit code to the memory then jump to it.  Getting this type of memory
--/// is very OS specific.
--///
--MemoryBlock
--Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock,
--                    std::string *ErrMsg) {
--  if (NumBytes == 0) return MemoryBlock();
--
--  static const size_t PageSize = Process::getPageSize();
--  size_t NumPages = (NumBytes+PageSize-1)/PageSize;
--
--  int fd = -1;
--
--  int flags = MAP_PRIVATE |
--#ifdef MAP_ANONYMOUS
--  MAP_ANONYMOUS
--#else
--  MAP_ANON
--#endif
--  ;
--
--  void* start = NearBlock ? (unsigned char*)NearBlock->base() +
--                            NearBlock->size() : nullptr;
--
--#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
--  void *pa = ::mmap(start, PageSize*NumPages, PROT_READ|PROT_EXEC,
--                    flags, fd, 0);
--#elif defined(__NetBSD__) && defined(PROT_MPROTECT)
--  void *pa =
--      ::mmap(start, PageSize * NumPages,
--             PROT_READ | PROT_WRITE | PROT_MPROTECT(PROT_EXEC), flags, fd, 0);
--#else
--  void *pa = ::mmap(start, PageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
--                    flags, fd, 0);
--#endif
--  if (pa == MAP_FAILED) {
--    if (NearBlock) //Try again without a near hint
--      return AllocateRWX(NumBytes, nullptr);
--
--    MakeErrMsg(ErrMsg, "Can't allocate RWX Memory");
--    return MemoryBlock();
--  }
--
--#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
--  kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)pa,
--                                (vm_size_t)(PageSize*NumPages), 0,
--                                VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_COPY);
--  if (KERN_SUCCESS != kr) {
--    MakeErrMsg(ErrMsg, "vm_protect max RX failed");
--    return MemoryBlock();
--  }
--
--  kr = vm_protect(mach_task_self(), (vm_address_t)pa,
--                  (vm_size_t)(PageSize*NumPages), 0,
--                  VM_PROT_READ | VM_PROT_WRITE);
--  if (KERN_SUCCESS != kr) {
--    MakeErrMsg(ErrMsg, "vm_protect RW failed");
--    return MemoryBlock();
--  }
--#endif
--
--  MemoryBlock result;
--  result.Address = pa;
--  result.Size = NumPages*PageSize;
--
--  return result;
--}
--
--bool Memory::ReleaseRWX(MemoryBlock &M, std::string *ErrMsg) {
--  if (M.Address == nullptr || M.Size == 0) return false;
--  if (0 != ::munmap(M.Address, M.Size))
--    return MakeErrMsg(ErrMsg, "Can't release RWX Memory");
--  return false;
--}
--
--bool Memory::setWritable (MemoryBlock &M, std::string *ErrMsg) {
--#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
--  if (M.Address == 0 || M.Size == 0) return false;
--  Memory::InvalidateInstructionCache(M.Address, M.Size);
--  kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)M.Address,
--    (vm_size_t)M.Size, 0, VM_PROT_READ | VM_PROT_WRITE);
--  return KERN_SUCCESS == kr;
--#else
--  return true;
--#endif
--}
--
--bool Memory::setExecutable (MemoryBlock &M, std::string *ErrMsg) {
--  if (M.Address == nullptr || M.Size == 0) return false;
--  Memory::InvalidateInstructionCache(M.Address, M.Size);
--#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
--  kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)M.Address,
--    (vm_size_t)M.Size, 0, VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_COPY);
--  return KERN_SUCCESS == kr;
--#else
--  return true;
--#endif
--}
--
--bool Memory::setRangeWritable(const void *Addr, size_t Size) {
--#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
--  kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)Addr,
--                                (vm_size_t)Size, 0,
--                                VM_PROT_READ | VM_PROT_WRITE);
--  return KERN_SUCCESS == kr;
--#else
--  return true;
--#endif
--}
--
--bool Memory::setRangeExecutable(const void *Addr, size_t Size) {
--#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
--  kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)Addr,
--                                (vm_size_t)Size, 0,
--                                VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_COPY);
--  return KERN_SUCCESS == kr;
--#else
--  return true;
--#endif
--}
--
--/// InvalidateInstructionCache - Before the JIT can run a block of code
--/// that has been emitted it must invalidate the instruction cache on some
--/// platforms.
--void Memory::InvalidateInstructionCache(const void *Addr,
--                                        size_t Len) {
--
--// icache invalidation for PPC and ARM.
--#if defined(__APPLE__)
--
--#  if (defined(__POWERPC__) || defined (__ppc__) || \
--       defined(_POWER) || defined(_ARCH_PPC) || defined(__arm__) || \
--       defined(__arm64__))
--  sys_icache_invalidate(const_cast<void *>(Addr), Len);
--#  endif
--
--#else
--
--#  if (defined(__POWERPC__) || defined (__ppc__) || \
--       defined(_POWER) || defined(_ARCH_PPC)) && defined(__GNUC__)
--  const size_t LineSize = 32;
--
--  const intptr_t Mask = ~(LineSize - 1);
--  const intptr_t StartLine = ((intptr_t) Addr) & Mask;
--  const intptr_t EndLine = ((intptr_t) Addr + Len + LineSize - 1) & Mask;
--
--  for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
--    asm volatile("dcbf 0, %0" : : "r"(Line));
--  asm volatile("sync");
--
--  for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
--    asm volatile("icbi 0, %0" : : "r"(Line));
--  asm volatile("isync");
--#  elif (defined(__arm__) || defined(__aarch64__) || defined(__mips__)) && \
--        defined(__GNUC__)
--  // FIXME: Can we safely always call this for __GNUC__ everywhere?
--  const char *Start = static_cast<const char *>(Addr);
--  const char *End = Start + Len;
--  __clear_cache(const_cast<char *>(Start), const_cast<char *>(End));
--#  endif
--
--#endif  // end apple
--
--  ValgrindDiscardTranslations(Addr, Len);
--}
--
- } // namespace sys
- } // namespace llvm
diff --git a/llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_AddressSanitizer.cpp b/llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_AddressSanitizer.cpp
new file mode 100644
index 0000000000..5639411b81
--- /dev/null
+++ b/llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_AddressSanitizer.cpp
@@ -0,0 +1,29 @@
+$NetBSD$
+
+--- lib/Transforms/Instrumentation/AddressSanitizer.cpp.orig	2017-07-04 15:51:35.232369546 +0000
++++ lib/Transforms/Instrumentation/AddressSanitizer.cpp
+@@ -80,6 +80,7 @@ static const uint64_t kMIPS64_ShadowOffs
+ static const uint64_t kAArch64_ShadowOffset64 = 1ULL << 36;
+ static const uint64_t kFreeBSD_ShadowOffset32 = 1ULL << 30;
+ static const uint64_t kFreeBSD_ShadowOffset64 = 1ULL << 46;
++static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46;
+ static const uint64_t kPS4CPU_ShadowOffset64 = 1ULL << 40;
+ static const uint64_t kWindowsShadowOffset32 = 3ULL << 28;
+ // The shadow memory space is dynamically allocated.
+@@ -394,6 +395,7 @@ static ShadowMapping getShadowMapping(Tr
+   bool IsAndroid = TargetTriple.isAndroid();
+   bool IsIOS = TargetTriple.isiOS() || TargetTriple.isWatchOS();
+   bool IsFreeBSD = TargetTriple.isOSFreeBSD();
++  bool IsNetBSD = TargetTriple.isOSNetBSD();
+   bool IsPS4CPU = TargetTriple.isPS4CPU();
+   bool IsLinux = TargetTriple.isOSLinux();
+   bool IsPPC64 = TargetTriple.getArch() == llvm::Triple::ppc64 ||
+@@ -438,6 +440,8 @@ static ShadowMapping getShadowMapping(Tr
+       Mapping.Offset = kSystemZ_ShadowOffset64;
+     else if (IsFreeBSD)
+       Mapping.Offset = kFreeBSD_ShadowOffset64;
++    else if (IsNetBSD)
++      Mapping.Offset = kNetBSD_ShadowOffset64;
+     else if (IsPS4CPU)
+       Mapping.Offset = kPS4CPU_ShadowOffset64;
+     else if (IsLinux && IsX86_64) {
diff --git a/llvm-netbsd/patches/patch-tools_lli_lli.cpp b/llvm-netbsd/patches/patch-tools_lli_lli.cpp
deleted file mode 100644
index 25d784b679..0000000000
--- a/llvm-netbsd/patches/patch-tools_lli_lli.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-$NetBSD$
-
---- tools/lli/lli.cpp.orig	2017-08-03 18:13:30.000000000 +0000
-+++ tools/lli/lli.cpp
-@@ -568,9 +568,6 @@ int main(int argc, char **argv, char * c
-     // Trigger compilation separately so code regions that need to be
-     // invalidated will be known.
-     (void)EE->getPointerToFunction(EntryFn);
--    // Clear instruction cache before code will be executed.
--    if (RTDyldMM)
--      static_cast<SectionMemoryManager*>(RTDyldMM)->invalidateInstructionCache();
- 
-     // Run main.
-     Result = EE->runFunctionAsMain(EntryFn, InputArgv, envp);
diff --git a/llvm-netbsd/patches/patch-tools_llvm-rtdyld_llvm-rtdyld.cpp b/llvm-netbsd/patches/patch-tools_llvm-rtdyld_llvm-rtdyld.cpp
deleted file mode 100644
index 905499f74b..0000000000
--- a/llvm-netbsd/patches/patch-tools_llvm-rtdyld_llvm-rtdyld.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-$NetBSD$
-
---- tools/llvm-rtdyld/llvm-rtdyld.cpp.orig	2017-07-20 19:13:57.000000000 +0000
-+++ tools/llvm-rtdyld/llvm-rtdyld.cpp
-@@ -178,10 +178,10 @@ public:
-   void deregisterEHFrames() override {}
- 
-   void preallocateSlab(uint64_t Size) {
--    std::string Err;
--    sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, &Err);
-+    std::error_code EC;
-+    sys::MemoryBlock MB = sys::Memory::allocateMappedMemory(Size, nullptr, sys::Memory::ProtectionMode::MF_WRITABLE, EC);
-     if (!MB.base())
--      report_fatal_error("Can't allocate enough memory: " + Err);
-+      report_fatal_error("Can't allocate enough memory");
- 
-     PreallocSlab = MB;
-     UsePreallocation = true;
-@@ -222,10 +222,10 @@ uint8_t *TrivialMemoryManager::allocateC
-   if (UsePreallocation)
-     return allocateFromSlab(Size, Alignment, true /* isCode */);
- 
--  std::string Err;
--  sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, &Err);
-+  std::error_code EC;
-+  sys::MemoryBlock MB = sys::Memory::allocateMappedMemory(Size, nullptr, sys::Memory::ProtectionMode::MF_WRITABLE, EC);
-   if (!MB.base())
--    report_fatal_error("MemoryManager allocation failed: " + Err);
-+    report_fatal_error("MemoryManager allocation failed");
-   FunctionMemory.push_back(MB);
-   return (uint8_t*)MB.base();
- }
-@@ -242,10 +242,10 @@ uint8_t *TrivialMemoryManager::allocateD
-   if (UsePreallocation)
-     return allocateFromSlab(Size, Alignment, false /* isCode */);
- 
--  std::string Err;
--  sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, &Err);
-+  std::error_code EC;
-+  sys::MemoryBlock MB = sys::Memory::allocateMappedMemory(Size, nullptr, sys::Memory::ProtectionMode::MF_WRITABLE, EC);
-   if (!MB.base())
--    report_fatal_error("MemoryManager allocation failed: " + Err);
-+    report_fatal_error("MemoryManager allocation failed");
-   DataMemory.push_back(MB);
-   return (uint8_t*)MB.base();
- }
-@@ -453,9 +453,10 @@ static int executeInput() {
- 
-     // Make sure the memory is executable.
-     // setExecutable will call InvalidateInstructionCache.
--    std::string ErrorStr;
--    if (!sys::Memory::setExecutable(FM, &ErrorStr))
--      ErrorAndExit("unable to mark function executable: '" + ErrorStr + "'");
-+    std::error_code EC;
-+    EC = sys::Memory::protectMappedMemory(FM, sys::Memory::ProtectionMode::MF_EXECUTABLE);
-+    if (EC)
-+      ErrorAndExit("unable to mark function executable");
-   }
- 
-   // Dispatch to _main().


Home | Main Index | Thread Index | Old Index