pkgsrc-WIP-changes archive

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

llvm-netbsd: Enable instrumentation on NetBSD in LLVM



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Thu Jun 29 22:38:44 2017 +0200
Changeset:	d088d8bd1c8cc27075d3f6d1947aa98e906ab8cc

Modified Files:
	llvm-netbsd/distinfo
Added Files:
	llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_AddressSanitizer.cpp
	llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_InstrProfiling.cpp
	llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_MemorySanitizer.cpp

Log Message:
llvm-netbsd: Enable instrumentation on NetBSD in LLVM

This covers ASAN, MSAN, PROFILING.

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=d088d8bd1c8cc27075d3f6d1947aa98e906ab8cc

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

diffstat:
 llvm-netbsd/distinfo                               |  3 ++
 ...Transforms_Instrumentation_AddressSanitizer.cpp | 29 +++++++++++++
 ...b_Transforms_Instrumentation_InstrProfiling.cpp | 12 ++++++
 ..._Transforms_Instrumentation_MemorySanitizer.cpp | 47 ++++++++++++++++++++++
 4 files changed, 91 insertions(+)

diffs:
diff --git a/llvm-netbsd/distinfo b/llvm-netbsd/distinfo
index 7931384fd5..2806df5770 100644
--- a/llvm-netbsd/distinfo
+++ b/llvm-netbsd/distinfo
@@ -12,3 +12,6 @@ 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-lib_Transforms_Instrumentation_AddressSanitizer.cpp) = 67eee29c4d8525b603e6b7c0a52278bdf3353687
+SHA1 (patch-lib_Transforms_Instrumentation_InstrProfiling.cpp) = 871b474f415d9dc468cc07477101f88d7a20868b
+SHA1 (patch-lib_Transforms_Instrumentation_MemorySanitizer.cpp) = aceb15e88db2619591e3fb92db85ccaf036c79df
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..a28fed92ae
--- /dev/null
+++ b/llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_AddressSanitizer.cpp
@@ -0,0 +1,29 @@
+$NetBSD$
+
+--- lib/Transforms/Instrumentation/AddressSanitizer.cpp.orig	2017-05-29 09:26:46.000000000 +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-lib_Transforms_Instrumentation_InstrProfiling.cpp b/llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_InstrProfiling.cpp
new file mode 100644
index 0000000000..e8229cc198
--- /dev/null
+++ b/llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_InstrProfiling.cpp
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- lib/Transforms/Instrumentation/InstrProfiling.cpp.orig	2017-06-17 16:34:37.000000000 +0000
++++ lib/Transforms/Instrumentation/InstrProfiling.cpp
+@@ -394,6 +394,7 @@ static bool needsRuntimeRegistrationOfSe
+   // Use linker script magic to get data/cnts/name start/end.
+   if (Triple(M.getTargetTriple()).isOSLinux() ||
+       Triple(M.getTargetTriple()).isOSFreeBSD() ||
++      Triple(M.getTargetTriple()).isOSNetBSD() ||
+       Triple(M.getTargetTriple()).isPS4CPU())
+     return false;
+ 
diff --git a/llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_MemorySanitizer.cpp b/llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_MemorySanitizer.cpp
new file mode 100644
index 0000000000..d6e1fd61ea
--- /dev/null
+++ b/llvm-netbsd/patches/patch-lib_Transforms_Instrumentation_MemorySanitizer.cpp
@@ -0,0 +1,47 @@
+$NetBSD$
+
+--- lib/Transforms/Instrumentation/MemorySanitizer.cpp.orig	2017-06-12 00:24:36.000000000 +0000
++++ lib/Transforms/Instrumentation/MemorySanitizer.cpp
+@@ -280,6 +280,14 @@ static const MemoryMapParams FreeBSD_X86
+   0x380000000000,  // OriginBase
+ };
+ 
++// x86_64 NetBSD
++static const MemoryMapParams NetBSD_X86_64_MemoryMapParams = {
++  0xc00000000000,  // AndMask
++  0x200000000000,  // XorMask
++  0x100000000000,  // ShadowBase
++  0x380000000000,  // OriginBase
++};
++
+ static const PlatformMemoryMapParams Linux_X86_MemoryMapParams = {
+   &Linux_I386_MemoryMapParams,
+   &Linux_X86_64_MemoryMapParams,
+@@ -305,6 +313,11 @@ static const PlatformMemoryMapParams Fre
+   &FreeBSD_X86_64_MemoryMapParams,
+ };
+ 
++static const PlatformMemoryMapParams FreeBSD_X86_MemoryMapParams = {
++  nullptr,
++  &NetBSD_X86_64_MemoryMapParams,
++};
++
+ /// \brief An instrumentation pass implementing detection of uninitialized
+ /// reads.
+ ///
+@@ -515,6 +528,15 @@ bool MemorySanitizer::doInitialization(M
+           report_fatal_error("unsupported architecture");
+       }
+       break;
++    case Triple::NetBSD:
++      switch (TargetTriple.getArch()) {
++        case Triple::x86_64:
++          MapParams = NetBSD_X86_MemoryMapParams.bits64;
++          break;
++        default:
++          report_fatal_error("unsupported architecture");
++      }
++      break;
+     case Triple::Linux:
+       switch (TargetTriple.getArch()) {
+         case Triple::x86_64:


Home | Main Index | Thread Index | Old Index