Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jan 2017 20:13:44 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r311536 - in vendor/compiler-rt/dist: cmake cmake/Modules lib/asan lib/asan/tests lib/builtins lib/sanitizer_common lib/scudo lib/ubsan test/builtins/Unit test/sanitizer_common/TestCases
Message-ID:  <201701062013.v06KDipZ068493@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Fri Jan  6 20:13:44 2017
New Revision: 311536
URL: https://svnweb.freebsd.org/changeset/base/311536

Log:
  Vendor import of compiler-rt trunk r291274:
  https://llvm.org/svn/llvm-project/compiler-rt/trunk@291274

Added:
  vendor/compiler-rt/dist/lib/builtins/floattitf.c   (contents, props changed)
  vendor/compiler-rt/dist/lib/builtins/floatuntitf.c   (contents, props changed)
  vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.cc   (contents, props changed)
  vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.h   (contents, props changed)
  vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.inc   (contents, props changed)
  vendor/compiler-rt/dist/test/builtins/Unit/floattitf_test.c   (contents, props changed)
  vendor/compiler-rt/dist/test/builtins/Unit/floatuntitf_test.c   (contents, props changed)
  vendor/compiler-rt/dist/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cc   (contents, props changed)
Modified:
  vendor/compiler-rt/dist/cmake/Modules/AddCompilerRT.cmake
  vendor/compiler-rt/dist/cmake/config-ix.cmake
  vendor/compiler-rt/dist/lib/asan/asan_allocator.cc
  vendor/compiler-rt/dist/lib/asan/asan_allocator.h
  vendor/compiler-rt/dist/lib/asan/asan_memory_profile.cc
  vendor/compiler-rt/dist/lib/asan/tests/asan_interface_test.cc
  vendor/compiler-rt/dist/lib/builtins/CMakeLists.txt
  vendor/compiler-rt/dist/lib/sanitizer_common/CMakeLists.txt
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_primary64.h
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common.cc
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common.h
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_internal_defs.h
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_procmaps.h
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_procmaps_mac.cc
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_quarantine.h
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_stacktrace.cc
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_win.cc
  vendor/compiler-rt/dist/lib/scudo/CMakeLists.txt
  vendor/compiler-rt/dist/lib/ubsan/ubsan_handlers.cc
  vendor/compiler-rt/dist/lib/ubsan/ubsan_handlers.h

Modified: vendor/compiler-rt/dist/cmake/Modules/AddCompilerRT.cmake
==============================================================================
--- vendor/compiler-rt/dist/cmake/Modules/AddCompilerRT.cmake	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/cmake/Modules/AddCompilerRT.cmake	Fri Jan  6 20:13:44 2017	(r311536)
@@ -256,6 +256,7 @@ set(COMPILER_RT_GTEST_CFLAGS
 )
 
 append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_UNITTEST_CFLAGS)
+append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG -Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS)
 
 if(MSVC)
   # clang doesn't support exceptions on Windows yet.

Modified: vendor/compiler-rt/dist/cmake/config-ix.cmake
==============================================================================
--- vendor/compiler-rt/dist/cmake/config-ix.cmake	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/cmake/config-ix.cmake	Fri Jan  6 20:13:44 2017	(r311536)
@@ -29,7 +29,6 @@ check_cxx_compiler_flag(-std=c++11      
 check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto             COMPILER_RT_HAS_FNO_LTO_FLAG)
 check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.          COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)
@@ -57,6 +56,7 @@ check_cxx_compiler_flag("-Werror -Wgnu" 
 check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor"   COMPILER_RT_HAS_WNON_VIRTUAL_DTOR_FLAG)
 check_cxx_compiler_flag("-Werror -Wvariadic-macros"    COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG)
 check_cxx_compiler_flag("-Werror -Wunused-parameter"   COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG)
+check_cxx_compiler_flag("-Werror -Wcovered-switch-default" COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG)
 
 check_cxx_compiler_flag(/W4 COMPILER_RT_HAS_W4_FLAG)
 check_cxx_compiler_flag(/WX COMPILER_RT_HAS_WX_FLAG)

Modified: vendor/compiler-rt/dist/lib/asan/asan_allocator.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_allocator.cc	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/asan/asan_allocator.cc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -681,6 +681,7 @@ struct Allocator {
 
   void PrintStats() {
     allocator.PrintStats();
+    quarantine.PrintStats();
   }
 
   void ForceLock() {
@@ -700,18 +701,21 @@ static AsanAllocator &get_allocator() {
   return instance.allocator;
 }
 
-bool AsanChunkView::IsValid() {
+bool AsanChunkView::IsValid() const {
   return chunk_ && chunk_->chunk_state != CHUNK_AVAILABLE;
 }
-bool AsanChunkView::IsAllocated() {
+bool AsanChunkView::IsAllocated() const {
   return chunk_ && chunk_->chunk_state == CHUNK_ALLOCATED;
 }
-uptr AsanChunkView::Beg() { return chunk_->Beg(); }
-uptr AsanChunkView::End() { return Beg() + UsedSize(); }
-uptr AsanChunkView::UsedSize() { return chunk_->UsedSize(); }
-uptr AsanChunkView::AllocTid() { return chunk_->alloc_tid; }
-uptr AsanChunkView::FreeTid() { return chunk_->free_tid; }
-AllocType AsanChunkView::GetAllocType() {
+bool AsanChunkView::IsQuarantined() const {
+  return chunk_ && chunk_->chunk_state == CHUNK_QUARANTINE;
+}
+uptr AsanChunkView::Beg() const { return chunk_->Beg(); }
+uptr AsanChunkView::End() const { return Beg() + UsedSize(); }
+uptr AsanChunkView::UsedSize() const { return chunk_->UsedSize(); }
+uptr AsanChunkView::AllocTid() const { return chunk_->alloc_tid; }
+uptr AsanChunkView::FreeTid() const { return chunk_->free_tid; }
+AllocType AsanChunkView::GetAllocType() const {
   return (AllocType)chunk_->alloc_type;
 }
 
@@ -722,14 +726,14 @@ static StackTrace GetStackTraceFromId(u3
   return res;
 }
 
-u32 AsanChunkView::GetAllocStackId() { return chunk_->alloc_context_id; }
-u32 AsanChunkView::GetFreeStackId() { return chunk_->free_context_id; }
+u32 AsanChunkView::GetAllocStackId() const { return chunk_->alloc_context_id; }
+u32 AsanChunkView::GetFreeStackId() const { return chunk_->free_context_id; }
 
-StackTrace AsanChunkView::GetAllocStack() {
+StackTrace AsanChunkView::GetAllocStack() const {
   return GetStackTraceFromId(GetAllocStackId());
 }
 
-StackTrace AsanChunkView::GetFreeStack() {
+StackTrace AsanChunkView::GetFreeStack() const {
   return GetStackTraceFromId(GetFreeStackId());
 }
 

Modified: vendor/compiler-rt/dist/lib/asan/asan_allocator.h
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_allocator.h	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/asan/asan_allocator.h	Fri Jan  6 20:13:44 2017	(r311536)
@@ -51,28 +51,29 @@ void GetAllocatorOptions(AllocatorOption
 class AsanChunkView {
  public:
   explicit AsanChunkView(AsanChunk *chunk) : chunk_(chunk) {}
-  bool IsValid();        // Checks if AsanChunkView points to a valid allocated
-                         // or quarantined chunk.
-  bool IsAllocated();    // Checks if the memory is currently allocated.
-  uptr Beg();            // First byte of user memory.
-  uptr End();            // Last byte of user memory.
-  uptr UsedSize();       // Size requested by the user.
-  uptr AllocTid();
-  uptr FreeTid();
+  bool IsValid() const;        // Checks if AsanChunkView points to a valid
+                               // allocated or quarantined chunk.
+  bool IsAllocated() const;    // Checks if the memory is currently allocated.
+  bool IsQuarantined() const;  // Checks if the memory is currently quarantined.
+  uptr Beg() const;            // First byte of user memory.
+  uptr End() const;            // Last byte of user memory.
+  uptr UsedSize() const;       // Size requested by the user.
+  uptr AllocTid() const;
+  uptr FreeTid() const;
   bool Eq(const AsanChunkView &c) const { return chunk_ == c.chunk_; }
-  u32 GetAllocStackId();
-  u32 GetFreeStackId();
-  StackTrace GetAllocStack();
-  StackTrace GetFreeStack();
-  AllocType GetAllocType();
-  bool AddrIsInside(uptr addr, uptr access_size, sptr *offset) {
+  u32 GetAllocStackId() const;
+  u32 GetFreeStackId() const;
+  StackTrace GetAllocStack() const;
+  StackTrace GetFreeStack() const;
+  AllocType GetAllocType() const;
+  bool AddrIsInside(uptr addr, uptr access_size, sptr *offset) const {
     if (addr >= Beg() && (addr + access_size) <= End()) {
       *offset = addr - Beg();
       return true;
     }
     return false;
   }
-  bool AddrIsAtLeft(uptr addr, uptr access_size, sptr *offset) {
+  bool AddrIsAtLeft(uptr addr, uptr access_size, sptr *offset) const {
     (void)access_size;
     if (addr < Beg()) {
       *offset = Beg() - addr;
@@ -80,7 +81,7 @@ class AsanChunkView {
     }
     return false;
   }
-  bool AddrIsAtRight(uptr addr, uptr access_size, sptr *offset) {
+  bool AddrIsAtRight(uptr addr, uptr access_size, sptr *offset) const {
     if (addr + access_size > End()) {
       *offset = addr - End();
       return true;

Modified: vendor/compiler-rt/dist/lib/asan/asan_memory_profile.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_memory_profile.cc	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/asan/asan_memory_profile.cc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -32,18 +32,20 @@ struct AllocationSite {
 class HeapProfile {
  public:
   HeapProfile() : allocations_(1024) {}
-  void Insert(u32 id, uptr size) {
-    total_allocated_ += size;
-    total_count_++;
-    // Linear lookup will be good enough for most cases (although not all).
-    for (uptr i = 0; i < allocations_.size(); i++) {
-      if (allocations_[i].id == id) {
-        allocations_[i].total_size += size;
-        allocations_[i].count++;
-        return;
-      }
+
+  void ProcessChunk(const AsanChunkView& cv) {
+    if (cv.IsAllocated()) {
+      total_allocated_user_size_ += cv.UsedSize();
+      total_allocated_count_++;
+      u32 id = cv.GetAllocStackId();
+      if (id)
+        Insert(id, cv.UsedSize());
+    } else if (cv.IsQuarantined()) {
+      total_quarantined_user_size_ += cv.UsedSize();
+      total_quarantined_count_++;
+    } else {
+      total_other_count_++;
     }
-    allocations_.push_back({id, size, 1});
   }
 
   void Print(uptr top_percent) {
@@ -51,34 +53,50 @@ class HeapProfile {
                  [](const AllocationSite &a, const AllocationSite &b) {
                    return a.total_size > b.total_size;
                  });
-    CHECK(total_allocated_);
+    CHECK(total_allocated_user_size_);
     uptr total_shown = 0;
-    Printf("Live Heap Allocations: %zd bytes from %zd allocations; "
-           "showing top %zd%%\n", total_allocated_, total_count_, top_percent);
+    Printf("Live Heap Allocations: %zd bytes in %zd chunks; quarantined: "
+           "%zd bytes in %zd chunks; %zd other chunks; total chunks: %zd; "
+           "showing top %zd%%\n",
+           total_allocated_user_size_, total_allocated_count_,
+           total_quarantined_user_size_, total_quarantined_count_,
+           total_other_count_, total_allocated_count_ +
+           total_quarantined_count_ + total_other_count_, top_percent);
     for (uptr i = 0; i < allocations_.size(); i++) {
       auto &a = allocations_[i];
       Printf("%zd byte(s) (%zd%%) in %zd allocation(s)\n", a.total_size,
-             a.total_size * 100 / total_allocated_, a.count);
+             a.total_size * 100 / total_allocated_user_size_, a.count);
       StackDepotGet(a.id).Print();
       total_shown += a.total_size;
-      if (total_shown * 100 / total_allocated_ > top_percent)
+      if (total_shown * 100 / total_allocated_user_size_ > top_percent)
         break;
     }
   }
 
  private:
-  uptr total_allocated_ = 0;
-  uptr total_count_ = 0;
+  uptr total_allocated_user_size_ = 0;
+  uptr total_allocated_count_ = 0;
+  uptr total_quarantined_user_size_ = 0;
+  uptr total_quarantined_count_ = 0;
+  uptr total_other_count_ = 0;
   InternalMmapVector<AllocationSite> allocations_;
+
+  void Insert(u32 id, uptr size) {
+    // Linear lookup will be good enough for most cases (although not all).
+    for (uptr i = 0; i < allocations_.size(); i++) {
+      if (allocations_[i].id == id) {
+        allocations_[i].total_size += size;
+        allocations_[i].count++;
+        return;
+      }
+    }
+    allocations_.push_back({id, size, 1});
+  }
 };
 
 static void ChunkCallback(uptr chunk, void *arg) {
-  HeapProfile *hp = reinterpret_cast<HeapProfile*>(arg);
-  AsanChunkView cv = FindHeapChunkByAllocBeg(chunk);
-  if (!cv.IsAllocated()) return;
-  u32 id = cv.GetAllocStackId();
-  if (!id) return;
-  hp->Insert(id, cv.UsedSize());
+  reinterpret_cast<HeapProfile*>(arg)->ProcessChunk(
+      FindHeapChunkByAllocBeg(chunk));
 }
 
 static void MemoryProfileCB(const SuspendedThreadsList &suspended_threads_list,

Modified: vendor/compiler-rt/dist/lib/asan/tests/asan_interface_test.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/tests/asan_interface_test.cc	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/asan/tests/asan_interface_test.cc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 #include "asan_test_utils.h"
+#include "sanitizer_common/sanitizer_internal_defs.h"
 #include <sanitizer/allocator_interface.h>
 #include <sanitizer/asan_interface.h>
 
@@ -399,7 +400,7 @@ static void ErrorReportCallbackOneToZ(co
 
 TEST(AddressSanitizerInterface, SetErrorReportCallbackTest) {
   __asan_set_error_report_callback(ErrorReportCallbackOneToZ);
-  EXPECT_DEATH(__asan_report_error(0, 0, 0, 0, true, 1),
+  EXPECT_DEATH(__asan_report_error((void *)GET_CALLER_PC(), 0, 0, 0, true, 1),
                ASAN_PCRE_DOTALL "ABCDEF.*AddressSanitizer.*WRITE.*ABCDEF");
   __asan_set_error_report_callback(NULL);
 }

Modified: vendor/compiler-rt/dist/lib/builtins/CMakeLists.txt
==============================================================================
--- vendor/compiler-rt/dist/lib/builtins/CMakeLists.txt	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/builtins/CMakeLists.txt	Fri Jan  6 20:13:44 2017	(r311536)
@@ -415,8 +415,10 @@ set(aarch64_SOURCES
   fixunstfti.c
   floatditf.c
   floatsitf.c
+  floattitf.c
   floatunditf.c
   floatunsitf.c
+  floatuntitf.c
   multc3.c
   trunctfdf2.c
   trunctfsf2.c

Added: vendor/compiler-rt/dist/lib/builtins/floattitf.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/compiler-rt/dist/lib/builtins/floattitf.c	Fri Jan  6 20:13:44 2017	(r311536)
@@ -0,0 +1,82 @@
+//===-- lib/floattitf.c - int128 -> quad-precision conversion -----*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements ti_int to quad-precision conversion for the
+// compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even
+// mode.
+//
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+#include "int_lib.h"
+
+/* Returns: convert a ti_int to a fp_t, rounding toward even. */
+
+/* Assumption: fp_t is a IEEE 128 bit floating point type
+ *             ti_int is a 128 bit integral type
+ */
+
+/* seee eeee eeee eeee mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm |
+ * mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+ */
+
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+COMPILER_RT_ABI fp_t
+__floattitf(ti_int a) {
+    if (a == 0)
+        return 0.0;
+    const unsigned N = sizeof(ti_int) * CHAR_BIT;
+    const ti_int s = a >> (N-1);
+    a = (a ^ s) - s;
+    int sd = N - __clzti2(a);  /* number of significant digits */
+    int e = sd - 1;            /* exponent */
+    if (sd > LDBL_MANT_DIG) {
+        /*  start:  0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
+         *  finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
+         *                                                12345678901234567890123456
+         *  1 = msb 1 bit
+         *  P = bit LDBL_MANT_DIG-1 bits to the right of 1
+         *  Q = bit LDBL_MANT_DIG bits to the right of 1
+         *  R = "or" of all bits to the right of Q
+         */
+        switch (sd) {
+        case LDBL_MANT_DIG + 1:
+            a <<= 1;
+            break;
+        case LDBL_MANT_DIG + 2:
+            break;
+        default:
+            a = ((tu_int)a >> (sd - (LDBL_MANT_DIG+2))) |
+                ((a & ((tu_int)(-1) >> ((N + LDBL_MANT_DIG+2) - sd))) != 0);
+        };
+        /* finish: */
+        a |= (a & 4) != 0;  /* Or P into R */
+        ++a;  /* round - this step may add a significant bit */
+        a >>= 2;  /* dump Q and R */
+        /* a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits */
+        if (a & ((tu_int)1 << LDBL_MANT_DIG)) {
+            a >>= 1;
+            ++e;
+        }
+        /* a is now rounded to LDBL_MANT_DIG bits */
+    } else {
+        a <<= (LDBL_MANT_DIG - sd);
+        /* a is now rounded to LDBL_MANT_DIG bits */
+    }
+
+    long_double_bits fb;
+    fb.u.high.all = (s & 0x8000000000000000LL)           /* sign */
+                  | (du_int)(e + 16383) << 48            /* exponent */
+                  | ((a >> 64) & 0x0000ffffffffffffLL);  /* significand */
+    fb.u.low.all = (du_int)(a);
+    return fb.f;
+}
+
+#endif

Added: vendor/compiler-rt/dist/lib/builtins/floatuntitf.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/compiler-rt/dist/lib/builtins/floatuntitf.c	Fri Jan  6 20:13:44 2017	(r311536)
@@ -0,0 +1,79 @@
+//===-- lib/floatuntitf.c - uint128 -> quad-precision conversion --*- C -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements tu_int to quad-precision conversion for the
+// compiler-rt library in the IEEE-754 default round-to-nearest, ties-to-even
+// mode.
+//
+//===----------------------------------------------------------------------===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+#include "int_lib.h"
+
+/* Returns: convert a tu_int to a fp_t, rounding toward even. */
+
+/* Assumption: fp_t is a IEEE 128 bit floating point type
+ *             tu_int is a 128 bit integral type
+ */
+
+/* seee eeee eeee eeee mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm |
+ * mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm
+ */
+
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+COMPILER_RT_ABI fp_t
+__floatuntitf(tu_int a) {
+    if (a == 0)
+        return 0.0;
+    const unsigned N = sizeof(tu_int) * CHAR_BIT;
+    int sd = N - __clzti2(a);  /* number of significant digits */
+    int e = sd - 1;            /* exponent */
+    if (sd > LDBL_MANT_DIG) {
+        /*  start:  0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
+         *  finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
+         *                                                12345678901234567890123456
+         *  1 = msb 1 bit
+         *  P = bit LDBL_MANT_DIG-1 bits to the right of 1
+         *  Q = bit LDBL_MANT_DIG bits to the right of 1
+         *  R = "or" of all bits to the right of Q
+         */
+        switch (sd) {
+        case LDBL_MANT_DIG + 1:
+            a <<= 1;
+            break;
+        case LDBL_MANT_DIG + 2:
+            break;
+        default:
+            a = (a >> (sd - (LDBL_MANT_DIG+2))) |
+                ((a & ((tu_int)(-1) >> ((N + LDBL_MANT_DIG+2) - sd))) != 0);
+        };
+        /* finish: */
+        a |= (a & 4) != 0;  /* Or P into R */
+        ++a;  /* round - this step may add a significant bit */
+        a >>= 2;  /* dump Q and R */
+        /* a is now rounded to LDBL_MANT_DIG or LDBL_MANT_DIG+1 bits */
+        if (a & ((tu_int)1 << LDBL_MANT_DIG)) {
+            a >>= 1;
+            ++e;
+        }
+        /* a is now rounded to LDBL_MANT_DIG bits */
+    } else {
+        a <<= (LDBL_MANT_DIG - sd);
+        /* a is now rounded to LDBL_MANT_DIG bits */
+    }
+
+    long_double_bits fb;
+    fb.u.high.all = (du_int)(e + 16383) << 48            /* exponent */
+                  | ((a >> 64) & 0x0000ffffffffffffLL);  /* significand */
+    fb.u.low.all = (du_int)(a);
+    return fb.f;
+}
+
+#endif

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/CMakeLists.txt
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/CMakeLists.txt	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/CMakeLists.txt	Fri Jan  6 20:13:44 2017	(r311536)
@@ -52,6 +52,7 @@ set(SANITIZER_NOLIBC_SOURCES
 
 set(SANITIZER_LIBCDEP_SOURCES
   sanitizer_common_libcdep.cc
+  sancov_flags.cc
   sanitizer_coverage_libcdep.cc
   sanitizer_coverage_libcdep_new.cc
   sanitizer_coverage_mapping_libcdep.cc

Added: vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.cc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -0,0 +1,60 @@
+//===-- sancov_flags.cc -----------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Sanitizer Coverage runtime flags.
+//
+//===----------------------------------------------------------------------===//
+
+#include "sancov_flags.h"
+#include "sanitizer_flag_parser.h"
+#include "sanitizer_platform.h"
+
+#if !SANITIZER_LINUX
+// other platforms do not have weak symbols out of the box.
+extern "C" const char* __sancov_default_options() { return ""; }
+#endif
+
+using namespace __sanitizer;
+
+namespace __sancov {
+
+SancovFlags sancov_flags_dont_use_directly;  // use via flags();
+
+void SancovFlags::SetDefaults() {
+#define SANCOV_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
+#include "sancov_flags.inc"
+#undef SANCOV_FLAG
+}
+
+static void RegisterSancovFlags(FlagParser *parser, SancovFlags *f) {
+#define SANCOV_FLAG(Type, Name, DefaultValue, Description) \
+  RegisterFlag(parser, #Name, Description, &f->Name);
+#include "sancov_flags.inc"
+#undef SANCOV_FLAG
+}
+
+static const char *MaybeCallSancovDefaultOptions() {
+  return (&__sancov_default_options) ? __sancov_default_options() : "";
+}
+
+void InitializeSancovFlags() {
+  SancovFlags *f = sancov_flags();
+  f->SetDefaults();
+
+  FlagParser parser;
+  RegisterSancovFlags(&parser, f);
+
+  parser.ParseString(MaybeCallSancovDefaultOptions());
+  parser.ParseString(GetEnv("SANCOV_OPTIONS"));
+
+  ReportUnrecognizedFlags();
+  if (f->help) parser.PrintFlagDescriptions();
+}
+
+}  // namespace __sancov

Added: vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.h	Fri Jan  6 20:13:44 2017	(r311536)
@@ -0,0 +1,40 @@
+//===-- sancov_flags.h ------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Sanitizer Coverage runtime flags.
+//
+//===----------------------------------------------------------------------===//
+#ifndef SANCOV_FLAGS_H
+#define SANCOV_FLAGS_H
+
+#include "sanitizer_flag_parser.h"
+#include "sanitizer_internal_defs.h"
+
+namespace __sancov {
+
+struct SancovFlags {
+#define SANCOV_FLAG(Type, Name, DefaultValue, Description) Type Name;
+#include "sancov_flags.inc"
+#undef SANCOV_FLAG
+
+  void SetDefaults();
+};
+
+extern SancovFlags sancov_flags_dont_use_directly;
+
+inline SancovFlags* sancov_flags() { return &sancov_flags_dont_use_directly; }
+
+void InitializeSancovFlags();
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE const char*
+__sancov_default_options();
+
+}  // namespace __sancov
+
+#endif

Added: vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.inc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.inc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -0,0 +1,21 @@
+//===-- sancov_flags.inc ----------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Sanitizer Coverage runtime flags.
+//
+//===----------------------------------------------------------------------===//
+#ifndef SANCOV_FLAG
+#error "Defnine SANCOV_FLAG prior to including this file!"
+#endif
+
+SANCOV_FLAG(bool, symbolize, true,
+            "If set, converage information will be symbolized by sancov tool "
+            "after dumping.")
+
+SANCOV_FLAG(bool, help, false, "Print flags help.")

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_primary64.h
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_primary64.h	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_primary64.h	Fri Jan  6 20:13:44 2017	(r311536)
@@ -227,9 +227,8 @@ class SizeClassAllocator64 {
     uptr in_use = region->n_allocated - region->n_freed;
     uptr avail_chunks = region->allocated_user / ClassIdToSize(class_id);
     Printf(
-        "  %02zd (%zd): mapped: %zdK allocs: %zd frees: %zd inuse: %zd "
-        "num_freed_chunks %zd"
-        " avail: %zd rss: %zdK releases: %zd\n",
+        "  %02zd (%6zd): mapped: %6zdK allocs: %7zd frees: %7zd inuse: %6zd "
+        "num_freed_chunks %7zd avail: %6zd rss: %6zdK releases: %6zd\n",
         class_id, ClassIdToSize(class_id), region->mapped_user >> 10,
         region->n_allocated, region->n_freed, in_use,
         region->num_freed_chunks, avail_chunks, rss >> 10,

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common.cc	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common.cc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -260,10 +260,12 @@ void LoadedModule::set(const char *modul
 }
 
 void LoadedModule::set(const char *module_name, uptr base_address,
-                       ModuleArch arch, u8 uuid[kModuleUUIDSize]) {
+                       ModuleArch arch, u8 uuid[kModuleUUIDSize],
+                       bool instrumented) {
   set(module_name, base_address);
   arch_ = arch;
   internal_memcpy(uuid_, uuid, sizeof(uuid_));
+  instrumented_ = instrumented;
 }
 
 void LoadedModule::clear() {
@@ -271,6 +273,7 @@ void LoadedModule::clear() {
   full_name_ = nullptr;
   arch_ = kModuleArchUnknown;
   internal_memset(uuid_, 0, kModuleUUIDSize);
+  instrumented_ = false;
   while (!ranges_.empty()) {
     AddressRange *r = ranges_.front();
     ranges_.pop_front();

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common.h
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common.h	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common.h	Fri Jan  6 20:13:44 2017	(r311536)
@@ -672,13 +672,16 @@ const uptr kModuleUUIDSize = 16;
 class LoadedModule {
  public:
   LoadedModule()
-      : full_name_(nullptr), base_address_(0), arch_(kModuleArchUnknown) {
+      : full_name_(nullptr),
+        base_address_(0),
+        arch_(kModuleArchUnknown),
+        instrumented_(false) {
     internal_memset(uuid_, 0, kModuleUUIDSize);
     ranges_.clear();
   }
   void set(const char *module_name, uptr base_address);
   void set(const char *module_name, uptr base_address, ModuleArch arch,
-           u8 uuid[kModuleUUIDSize]);
+           u8 uuid[kModuleUUIDSize], bool instrumented);
   void clear();
   void addAddressRange(uptr beg, uptr end, bool executable);
   bool containsAddress(uptr address) const;
@@ -687,6 +690,7 @@ class LoadedModule {
   uptr base_address() const { return base_address_; }
   ModuleArch arch() const { return arch_; }
   const u8 *uuid() const { return uuid_; }
+  bool instrumented() const { return instrumented_; }
 
   struct AddressRange {
     AddressRange *next;
@@ -705,6 +709,7 @@ class LoadedModule {
   uptr base_address_;
   ModuleArch arch_;
   u8 uuid_[kModuleUUIDSize];
+  bool instrumented_;
   IntrusiveList<AddressRange> ranges_;
 };
 

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 // Sanitizer Coverage Controller for Trace PC Guard.
 
+#include "sancov_flags.h"
 #include "sanitizer_allocator_internal.h"
 #include "sanitizer_atomic.h"
 #include "sanitizer_common.h"
@@ -17,6 +18,7 @@ using namespace __sanitizer;
 
 using AddressRange = LoadedModule::AddressRange;
 
+namespace __sancov {
 namespace {
 
 static const u64 Magic64 = 0xC0BFFFFFFFFFFF64ULL;
@@ -96,6 +98,10 @@ static void SanitizerDumpCoverage(const 
   InternalFree(file_path);
   InternalFree(module_name);
   InternalFree(pcs);
+
+  if (sancov_flags()->symbolize) {
+    Printf("TODO(aizatsky): call sancov to symbolize\n");
+  }
 }
 
 // Collects trace-pc guard coverage.
@@ -106,6 +112,8 @@ class TracePcGuardController {
     CHECK(!initialized);
 
     initialized = true;
+    InitializeSancovFlags();
+
     pc_vector.Initialize(0);
   }
 
@@ -140,26 +148,27 @@ class TracePcGuardController {
 static TracePcGuardController pc_guard_controller;
 
 }  // namespace
+}  // namespace __sancov
 
 extern "C" {
 SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_coverage(  // NOLINT
     const uptr* pcs, uptr len) {
-  return SanitizerDumpCoverage(pcs, len);
+  return __sancov::SanitizerDumpCoverage(pcs, len);
 }
 
 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
 __sanitizer_cov_trace_pc_guard(u32* guard) {
   if (!*guard) return;
-  pc_guard_controller.TracePcGuard(guard, GET_CALLER_PC() - 1);
+  __sancov::pc_guard_controller.TracePcGuard(guard, GET_CALLER_PC() - 1);
 }
 
 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
 __sanitizer_cov_trace_pc_guard_init(u32* start, u32* end) {
   if (start == end || *start) return;
-  pc_guard_controller.InitTracePcGuard(start, end);
+  __sancov::pc_guard_controller.InitTracePcGuard(start, end);
 }
 
 SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_dump_trace_pc_guard_coverage() {
-  pc_guard_controller.Dump();
+  __sancov::pc_guard_controller.Dump();
 }
 }  // extern "C"

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_internal_defs.h
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_internal_defs.h	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_internal_defs.h	Fri Jan  6 20:13:44 2017	(r311536)
@@ -289,8 +289,8 @@ void NORETURN CheckFailed(const char *fi
 enum LinkerInitialized { LINKER_INITIALIZED = 0 };
 
 #if !defined(_MSC_VER) || defined(__clang__)
-# define GET_CALLER_PC() (uptr)__builtin_return_address(0)
-# define GET_CURRENT_FRAME() (uptr)__builtin_frame_address(0)
+#define GET_CALLER_PC() (__sanitizer::uptr) __builtin_return_address(0)
+#define GET_CURRENT_FRAME() (__sanitizer::uptr) __builtin_frame_address(0)
 inline void Trap() {
   __builtin_trap();
 }
@@ -299,9 +299,10 @@ extern "C" void* _ReturnAddress(void);
 extern "C" void* _AddressOfReturnAddress(void);
 # pragma intrinsic(_ReturnAddress)
 # pragma intrinsic(_AddressOfReturnAddress)
-# define GET_CALLER_PC() (uptr)_ReturnAddress()
+#define GET_CALLER_PC() (__sanitizer::uptr) _ReturnAddress()
 // CaptureStackBackTrace doesn't need to know BP on Windows.
-# define GET_CURRENT_FRAME() (((uptr)_AddressOfReturnAddress()) + sizeof(uptr))
+#define GET_CURRENT_FRAME() \
+  (((__sanitizer::uptr)_AddressOfReturnAddress()) + sizeof(__sanitizer::uptr))
 
 extern "C" void __ud2(void);
 # pragma intrinsic(__ud2)
@@ -319,11 +320,11 @@ inline void Trap() {
   }
 
 // Forces the compiler to generate a frame pointer in the function.
-#define ENABLE_FRAME_POINTER                                       \
-  do {                                                             \
-    volatile uptr enable_fp;                                       \
-    enable_fp = GET_CURRENT_FRAME();                               \
-    (void)enable_fp;                                               \
+#define ENABLE_FRAME_POINTER              \
+  do {                                    \
+    volatile __sanitizer::uptr enable_fp; \
+    enable_fp = GET_CURRENT_FRAME();      \
+    (void)enable_fp;                      \
   } while (0)
 
 }  // namespace __sanitizer

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_procmaps.h
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_procmaps.h	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_procmaps.h	Fri Jan  6 20:13:44 2017	(r311536)
@@ -77,6 +77,7 @@ class MemoryMappingLayout {
   u8 current_uuid_[kModuleUUIDSize];
   int current_load_cmd_count_;
   char *current_load_cmd_addr_;
+  bool current_instrumented_;
 # endif
 };
 

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_procmaps_mac.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_procmaps_mac.cc	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_procmaps_mac.cc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -150,22 +150,36 @@ ModuleArch ModuleArchFromCpuType(cpu_typ
   }
 }
 
+static const load_command *NextCommand(const load_command *lc) {
+  return (const load_command *)((char *)lc + lc->cmdsize);
+}
+
 static void FindUUID(const load_command *first_lc, u8 *uuid_output) {
-  const load_command *current_lc = first_lc;
-  while (1) {
-    if (current_lc->cmd == 0) return;
-    if (current_lc->cmd == LC_UUID) {
-      const uuid_command *uuid_lc = (const uuid_command *)current_lc;
-      const uint8_t *uuid = &uuid_lc->uuid[0];
-      internal_memcpy(uuid_output, uuid, kModuleUUIDSize);
-      return;
-    }
+  for (const load_command *lc = first_lc; lc->cmd != 0; lc = NextCommand(lc)) {
+    if (lc->cmd != LC_UUID) continue;
 
-    current_lc =
-        (const load_command *)(((char *)current_lc) + current_lc->cmdsize);
+    const uuid_command *uuid_lc = (const uuid_command *)lc;
+    const uint8_t *uuid = &uuid_lc->uuid[0];
+    internal_memcpy(uuid_output, uuid, kModuleUUIDSize);
+    return;
   }
 }
 
+static bool IsModuleInstrumented(const load_command *first_lc) {
+  for (const load_command *lc = first_lc; lc->cmd != 0; lc = NextCommand(lc)) {
+    if (lc->cmd != LC_LOAD_DYLIB) continue;
+
+    const dylib_command *dylib_lc = (const dylib_command *)lc;
+    uint32_t dylib_name_offset = dylib_lc->dylib.name.offset;
+    const char *dylib_name = ((const char *)dylib_lc) + dylib_name_offset;
+    dylib_name = StripModuleName(dylib_name);
+    if (dylib_name != 0 && (internal_strstr(dylib_name, "libclang_rt."))) {
+      return true;
+    }
+  }
+  return false;
+}
+
 bool MemoryMappingLayout::Next(uptr *start, uptr *end, uptr *offset,
                                char filename[], uptr filename_size,
                                uptr *protection, ModuleArch *arch, u8 *uuid) {
@@ -193,10 +207,11 @@ bool MemoryMappingLayout::Next(uptr *sta
           continue;
         }
       }
+      FindUUID((const load_command *)current_load_cmd_addr_, &current_uuid_[0]);
+      current_instrumented_ =
+          IsModuleInstrumented((const load_command *)current_load_cmd_addr_);
     }
 
-    FindUUID((const load_command *)current_load_cmd_addr_, &current_uuid_[0]);
-
     for (; current_load_cmd_count_ >= 0; current_load_cmd_count_--) {
       switch (current_magic_) {
         // current_magic_ may be only one of MH_MAGIC, MH_MAGIC_64.
@@ -244,7 +259,8 @@ void MemoryMappingLayout::DumpListOfModu
     } else {
       modules->push_back(LoadedModule());
       cur_module = &modules->back();
-      cur_module->set(cur_name, cur_beg, cur_arch, cur_uuid);
+      cur_module->set(cur_name, cur_beg, cur_arch, cur_uuid,
+                      current_instrumented_);
     }
     cur_module->addAddressRange(cur_beg, cur_end, prot & kProtectionExecute);
   }

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_quarantine.h
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_quarantine.h	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_quarantine.h	Fri Jan  6 20:13:44 2017	(r311536)
@@ -73,6 +73,11 @@ class Quarantine {
       Recycle(cb);
   }
 
+  void PrintStats() const {
+    // It assumes that the world is stopped, just as the allocator's PrintStats.
+    cache_.PrintStats();
+  }
+
  private:
   // Read-only data.
   char pad0_[kCacheLineSize];
@@ -163,8 +168,25 @@ class QuarantineCache {
     return b;
   }
 
+  void PrintStats() const {
+    uptr batch_count = 0;
+    uptr total_quarantine_bytes = 0;
+    uptr total_quarantine_chunks = 0;
+    for (List::ConstIterator it = list_.begin(); it != list_.end(); ++it) {
+      batch_count++;
+      total_quarantine_bytes += (*it).size;
+      total_quarantine_chunks += (*it).count;
+    }
+    Printf("Global quarantine stats: batches: %zd; bytes: %zd; chunks: %zd "
+           "(capacity: %zd chunks)\n",
+           batch_count, total_quarantine_bytes, total_quarantine_chunks,
+           batch_count * QuarantineBatch::kSize);
+  }
+
  private:
-  IntrusiveList<QuarantineBatch> list_;
+  typedef IntrusiveList<QuarantineBatch> List;
+
+  List list_;
   atomic_uintptr_t size_;
 
   void SizeAdd(uptr add) {

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_stacktrace.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_stacktrace.cc	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_stacktrace.cc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -106,10 +106,6 @@ void BufferedStackTrace::FastUnwindStack
   }
 }
 
-static bool MatchPc(uptr cur_pc, uptr trace_pc, uptr threshold) {
-  return cur_pc - trace_pc <= threshold || trace_pc - cur_pc <= threshold;
-}
-
 void BufferedStackTrace::PopStackFrames(uptr count) {
   CHECK_LT(count, size);
   size -= count;
@@ -118,15 +114,14 @@ void BufferedStackTrace::PopStackFrames(
   }
 }
 
+static uptr Distance(uptr a, uptr b) { return a < b ? b - a : a - b; }
+
 uptr BufferedStackTrace::LocatePcInTrace(uptr pc) {
-  // Use threshold to find PC in stack trace, as PC we want to unwind from may
-  // slightly differ from return address in the actual unwinded stack trace.
-  const int kPcThreshold = 350;
-  for (uptr i = 0; i < size; ++i) {
-    if (MatchPc(pc, trace[i], kPcThreshold))
-      return i;
+  uptr best = 0;
+  for (uptr i = 1; i < size; ++i) {
+    if (Distance(trace[i], pc) < Distance(trace[best], pc)) best = i;
   }
-  return 0;
+  return best;
 }
 
 }  // namespace __sanitizer

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_win.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_win.cc	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_win.cc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -31,6 +31,21 @@
 #include "sanitizer_stacktrace.h"
 #include "sanitizer_symbolizer.h"
 
+// A macro to tell the compiler that this part of the code cannot be reached,
+// if the compiler supports this feature. Since we're using this in
+// code that is called when terminating the process, the expansion of the
+// macro should not terminate the process to avoid infinite recursion.
+#if defined(__clang__)
+# define BUILTIN_UNREACHABLE() __builtin_unreachable()
+#elif defined(__GNUC__) && \
+    (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+# define BUILTIN_UNREACHABLE() __builtin_unreachable()
+#elif defined(_MSC_VER)
+# define BUILTIN_UNREACHABLE() __assume(0)
+#else
+# define BUILTIN_UNREACHABLE()
+#endif
+
 namespace __sanitizer {
 
 #include "sanitizer_syscall_generic.inc"
@@ -659,7 +674,7 @@ void internal__exit(int exitcode) {
   if (::IsDebuggerPresent())
     __debugbreak();
   TerminateProcess(GetCurrentProcess(), exitcode);
-  __assume(0);
+  BUILTIN_UNREACHABLE();
 }
 
 uptr internal_ftruncate(fd_t fd, uptr size) {

Modified: vendor/compiler-rt/dist/lib/scudo/CMakeLists.txt
==============================================================================
--- vendor/compiler-rt/dist/lib/scudo/CMakeLists.txt	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/scudo/CMakeLists.txt	Fri Jan  6 20:13:44 2017	(r311536)
@@ -4,7 +4,6 @@ include_directories(..)
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp

Modified: vendor/compiler-rt/dist/lib/ubsan/ubsan_handlers.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/ubsan/ubsan_handlers.cc	Fri Jan  6 20:13:41 2017	(r311535)
+++ vendor/compiler-rt/dist/lib/ubsan/ubsan_handlers.cc	Fri Jan  6 20:13:44 2017	(r311536)
@@ -45,10 +45,11 @@ static void handleTypeMismatchImpl(TypeM
                                    ReportOptions Opts) {
   Location Loc = Data->Loc.acquire();
 
+  uptr Alignment = (uptr)1 << Data->LogAlignment;
   ErrorType ET;
   if (!Pointer)
     ET = ErrorType::NullPointerUse;
-  else if (Data->Alignment && (Pointer & (Data->Alignment - 1)))
+  else if (Pointer & (Alignment - 1))
     ET = ErrorType::MisalignedPointerUse;
   else
     ET = ErrorType::InsufficientObjectSize;
@@ -74,8 +75,8 @@ static void handleTypeMismatchImpl(TypeM
   case ErrorType::MisalignedPointerUse:
     Diag(Loc, DL_Error, "%0 misaligned address %1 for type %3, "
                         "which requires %2 byte alignment")
-        << TypeCheckKinds[Data->TypeCheckKind] << (void *)Pointer
-        << Data->Alignment << Data->Type;
+        << TypeCheckKinds[Data->TypeCheckKind] << (void *)Pointer << Alignment
+        << Data->Type;
     break;
   case ErrorType::InsufficientObjectSize:
     Diag(Loc, DL_Error, "%0 address %1 with insufficient space "
@@ -90,13 +91,13 @@ static void handleTypeMismatchImpl(TypeM
     Diag(Pointer, DL_Note, "pointer points here");
 }

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701062013.v06KDipZ068493>