[llvm-branch-commits] [compiler-rt] bce25ef - Patches from emscripten 3.1.11

2022-09-06 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2022-05-22T19:15:19-07:00
New Revision: bce25ef66596b013cd61c322c0098f89e43e92f6

URL: 
https://github.com/llvm/llvm-project/commit/bce25ef66596b013cd61c322c0098f89e43e92f6
DIFF: 
https://github.com/llvm/llvm-project/commit/bce25ef66596b013cd61c322c0098f89e43e92f6.diff

LOG: Patches from emscripten 3.1.11

Added: 


Modified: 
compiler-rt/lib/lsan/lsan_common.cpp
compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
libcxx/include/__config

Removed: 




diff  --git a/compiler-rt/lib/lsan/lsan_common.cpp 
b/compiler-rt/lib/lsan/lsan_common.cpp
index b52106537a677..1a7a3d4203d4e 100644
--- a/compiler-rt/lib/lsan/lsan_common.cpp
+++ b/compiler-rt/lib/lsan/lsan_common.cpp
@@ -185,6 +185,14 @@ static uptr GetCallerPC(const StackTrace &stack) {
 // valid before reporting chunks as leaked.
 bool LeakSuppressionContext::SuppressInvalid(const StackTrace &stack) {
   uptr caller_pc = GetCallerPC(stack);
+#if SANITIZER_EMSCRIPTEN
+  // caller_pr will always be 0 if we use malloc_context_size=0 (or 1) which
+  // we recommend under emscripten to save memory.  It seems that this setting
+  // now (inadvertently?) suppreses all leaks.
+  // See https://reviews.llvm.org/D115319#3526676.
+  if (!caller_pc)
+return false;
+#endif
   // If caller_pc is unknown, this chunk may be allocated in a coroutine. Mark
   // it as reachable, as we can't properly report its allocation stack anyway.
   return !caller_pc ||
@@ -313,7 +321,7 @@ void ScanRangeForPointers(uptr begin, uptr end, Frontier 
*frontier,
 #if SANITIZER_EMSCRIPTEN && !defined(__EMSCRIPTEN_PTHREADS__)
 if (cache_begin <= pp && pp < cache_end) {
   LOG_POINTERS("%p: skipping because it overlaps the cache %p-%p.\n",
-  pp, cache_begin, cache_end);
+  (void*)pp, (void*)cache_begin, (void*)cache_end);
   continue;
 }
 #endif
@@ -804,53 +812,6 @@ static int DoRecoverableLeakCheck() {
 
 void DoRecoverableLeakCheckVoid() { DoRecoverableLeakCheck(); }
 
-<<< HEAD
-===
-Suppression *LeakSuppressionContext::GetSuppressionForAddr(uptr addr) {
-  Suppression *s = nullptr;
-
-  // Suppress by module name.
-  if (const char *module_name =
-  Symbolizer::GetOrInit()->GetModuleNameForPc(addr))
-if (context.Match(module_name, kSuppressionLeak, &s))
-  return s;
-
-  // Suppress by file or function name.
-  SymbolizedStack *frames = Symbolizer::GetOrInit()->SymbolizePC(addr);
-  for (SymbolizedStack *cur = frames; cur; cur = cur->next) {
-if (context.Match(cur->info.function, kSuppressionLeak, &s) ||
-context.Match(cur->info.file, kSuppressionLeak, &s)) {
-  break;
-}
-  }
-  frames->ClearAll();
-  return s;
-}
-
-Suppression *LeakSuppressionContext::GetSuppressionForStack(
-u32 stack_trace_id) {
-  LazyInit();
-  StackTrace stack = StackDepotGet(stack_trace_id);
-  for (uptr i = 0; i < stack.size; i++) {
-#if SANITIZER_EMSCRIPTEN
-// On Emscripten, the stack trace is the actual call site, not
-// the code that would be executed after the return.
-// Therefore, StackTrace::GetPreviousInstructionPc is not needed.
-Suppression *s = GetSuppressionForAddr(stack.trace[i]);
-#else
-Suppression *s = GetSuppressionForAddr(
-StackTrace::GetPreviousInstructionPc(stack.trace[i]));
-#endif
-if (s) {
-  suppressed_stacks_sorted = false;
-  suppressed_stacks.push_back(stack_trace_id);
-  return s;
-}
-  }
-  return nullptr;
-}
-
->>> 2bbe2c4b7413 (Rebase of changed from emscripten-libs-12.0.0 onto 
llvmorg-13.0.0)
 / LeakReport implementation. /
 
 // A hard limit on the number of distinct leaks, to avoid quadratic complexity

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
index 7fa8008589b63..fee0ba277 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
@@ -139,7 +139,7 @@ namespace __sanitizer {
 typedef unsigned long long uptr;
 typedef signed long long sptr;
 #else
-#  if (SANITIZER_WORDSIZE == 64) || SANITIZER_MAC || SANITIZER_WINDOWS
+#  if (SANITIZER_WORDSIZE == 64) || SANITIZER_MAC || SANITIZER_WINDOWS || 
SANITIZER_EMSCRIPTEN
 typedef unsigned long uptr;
 typedef signed long sptr;
 #  else

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
index 4269fed630051..32b96dbdf96f7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
@@ -145,11 +145,19 @@ void *MmapFixedOrDieOnFatalError(uptr fixed_addr, uptr 
size, const char *name) {
 }
 
 bool MprotectNoAccess(uptr addr, uptr size) {
+#if SANITIZER_EMSCRIPTEN
+  return true;
+#else
   return 0 == int

[llvm-branch-commits] [libcxx] bfd609f - Patches from emscripten 3.1.12

2022-09-06 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2022-05-27T19:01:47-07:00
New Revision: bfd609f67960b463229f0167b5ca720f70319797

URL: 
https://github.com/llvm/llvm-project/commit/bfd609f67960b463229f0167b5ca720f70319797
DIFF: 
https://github.com/llvm/llvm-project/commit/bfd609f67960b463229f0167b5ca720f70319797.diff

LOG: Patches from emscripten 3.1.12

Added: 


Modified: 
libcxx/include/__locale
libcxx/src/include/config_elast.h

Removed: 




diff  --git a/libcxx/include/__locale b/libcxx/include/__locale
index 51f35eece7121..08db4bcbe01e8 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -34,8 +34,7 @@
 # include <__support/newlib/xlocale.h>
 #elif defined(__OpenBSD__)
 # include <__support/openbsd/xlocale.h>
-#elif (defined(__APPLE__)  || defined(__FreeBSD__) \
-|| defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
+#elif (defined(__APPLE__) || defined(__FreeBSD__) || defined(__IBMCPP__))
 # include 
 #elif defined(__Fuchsia__)
 # include <__support/fuchsia/xlocale.h>

diff  --git a/libcxx/src/include/config_elast.h 
b/libcxx/src/include/config_elast.h
index 13e1624a97ee3..bef26ec5019ec 100644
--- a/libcxx/src/include/config_elast.h
+++ b/libcxx/src/include/config_elast.h
@@ -29,12 +29,12 @@
 // No _LIBCPP_ELAST needed on Fuchsia
 #elif defined(__wasi__)
 // No _LIBCPP_ELAST needed on WASI
+#elif defined(__EMSCRIPTEN__)
+// No _LIBCPP_ELAST needed on Emscripten
 #elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 #define _LIBCPP_ELAST 4095
 #elif defined(__APPLE__)
 // No _LIBCPP_ELAST needed on Apple
-#elif defined(__EMSCRIPTEN__) // XXX EMSCRIPTEN added ELAST value
-#define _LIBCPP_ELAST 256
 #elif defined(__sun__)
 #define _LIBCPP_ELAST ESTALE
 #elif defined(__MVS__)



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] 5fd26fb - Patches from emscripten 3.1.20

2022-09-06 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2022-09-06T02:21:33-07:00
New Revision: 5fd26fb4fcb1657bff8fc489cf6cd8628993f71c

URL: 
https://github.com/llvm/llvm-project/commit/5fd26fb4fcb1657bff8fc489cf6cd8628993f71c
DIFF: 
https://github.com/llvm/llvm-project/commit/5fd26fb4fcb1657bff8fc489cf6cd8628993f71c.diff

LOG: Patches from emscripten 3.1.20

Added: 


Modified: 
compiler-rt/lib/asan/asan_globals.cpp
compiler-rt/lib/lsan/lsan_interceptors.cpp
compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp

Removed: 




diff  --git a/compiler-rt/lib/asan/asan_globals.cpp 
b/compiler-rt/lib/asan/asan_globals.cpp
index ecc2600f039a1..fa050988e5351 100644
--- a/compiler-rt/lib/asan/asan_globals.cpp
+++ b/compiler-rt/lib/asan/asan_globals.cpp
@@ -315,6 +315,7 @@ void PrintGlobalLocation(InternalScopedString *str, const 
__asan_global &g) {
 // -- Interface  {{{1
 using namespace __asan;
 
+#if !SANITIZER_EMSCRIPTEN
 // Apply __asan_register_globals to all globals found in the same loaded
 // executable or shared library as `flag'. The flag tracks whether globals have
 // already been registered or not for this image.
@@ -352,6 +353,7 @@ void __asan_unregister_elf_globals(uptr *flag, void *start, 
void *stop) {
   __asan_unregister_globals(globals_start, globals_stop - globals_start);
   *flag = 0;
 }
+#endif
 
 // Register an array of globals.
 void __asan_register_globals(__asan_global *globals, uptr n) {

diff  --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp 
b/compiler-rt/lib/lsan/lsan_interceptors.cpp
index c7032032ff9a7..00c0428f4a8bb 100644
--- a/compiler-rt/lib/lsan/lsan_interceptors.cpp
+++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp
@@ -32,6 +32,17 @@
 #include "lsan_common.h"
 #include "lsan_thread.h"
 
+#if SANITIZER_EMSCRIPTEN
+#define __ATTRP_C11_THREAD ((void*)(uptr)-1)
+#include 
+extern "C" {
+int emscripten_builtin_pthread_create(void *thread, void *attr,
+  void *(*callback)(void *), void *arg);
+int emscripten_builtin_pthread_join(void *th, void **ret);
+int emscripten_builtin_pthread_detach(void *th);
+}
+#endif
+
 #include 
 
 using namespace __lsan;
@@ -403,18 +414,6 @@ INTERCEPTOR(int, pthread_atfork, void (*prepare)(), void 
(*parent)(),
 #define LSAN_MAYBE_INTERCEPT_PTHREAD_ATFORK
 #endif
 
-#if SANITIZER_EMSCRIPTEN
-#define __ATTRP_C11_THREAD ((void*)(uptr)-1)
-extern "C" {
-  int emscripten_builtin_pthread_create(void *thread, void *attr,
-void *(*callback)(void *), void *arg);
-  int emscripten_builtin_pthread_join(void *th, void **ret);
-  int emscripten_builtin_pthread_detach(void *th);
-  void *emscripten_builtin_malloc(size_t size);
-  void emscripten_builtin_free(void *);
-}
-#endif
-
 #if SANITIZER_INTERCEPT_STRERROR
 INTERCEPTOR(char *, strerror, int errnum) {
   __lsan::ScopedInterceptorDisabler disabler;

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
index c4cc0e45193ea..c64b0955b78c5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
@@ -78,6 +78,7 @@ void *BackgroundThread(void *arg) {
   }
 }
 
+#if !SANITIZER_EMSCRIPTEN
 void MaybeStartBackgroudThread() {
   // Need to implement/test on other platforms.
   // Start the background thread if one of the rss limits is given.
@@ -110,6 +111,7 @@ static struct BackgroudThreadStarted {
 #else
 void MaybeStartBackgroudThread() {}
 #endif
+#endif
 
 void WriteToSyslog(const char *msg) {
   InternalScopedString msg_copy;

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index ef0b0167fb3a6..33e7f017aac83 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -59,7 +59,7 @@
 #include 
 #include 
 #include 
-#if !SANITIZER_SOLARIS
+#if !SANITIZER_SOLARIS && !SANITIZER_EMSCRIPTEN
 #include 
 #endif
 #include 
@@ -596,7 +596,9 @@ u64 NanoTime() {
 #endif
 
 #if SANITIZER_EMSCRIPTEN
+extern "C" {
 int __clock_gettime(__sanitizer_clockid_t clk_id, void *tp);
+}
 
 uptr internal_clock_gettime(__sanitizer_clockid_t clk_id, void *tp) {
   return __clock_gettime(clk_id, tp);
@@ -1850,7 +1852,7 @@ HandleSignalMode GetHandleSignalMode(int signum) {
   return result;
 }
 
-#if !SANITIZER_GO
+#if !SANITIZER_GO && !SANITIZER

[llvm-branch-commits] [compiler-rt] 57626a5 - Rebase of changed from emscripten-libs-13.0.0 onto llvmorg-14.0.0

2022-09-06 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2022-05-22T19:08:19-07:00
New Revision: 57626a57ad4bb35367f0b361bd80ceb3266a

URL: 
https://github.com/llvm/llvm-project/commit/57626a57ad4bb35367f0b361bd80ceb3266a
DIFF: 
https://github.com/llvm/llvm-project/commit/57626a57ad4bb35367f0b361bd80ceb3266a.diff

LOG: Rebase of changed from emscripten-libs-13.0.0 onto llvmorg-14.0.0

Added: 


Modified: 
compiler-rt/lib/asan/asan_errors.cpp
compiler-rt/lib/asan/asan_flags.cpp
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp
compiler-rt/lib/asan/asan_malloc_linux.cpp
compiler-rt/lib/asan/asan_mapping.h
compiler-rt/lib/asan/asan_poisoning.cpp
compiler-rt/lib/asan/asan_poisoning.h
compiler-rt/lib/asan/asan_posix.cpp
compiler-rt/lib/asan/asan_rtl.cpp
compiler-rt/lib/asan/asan_shadow_setup.cpp
compiler-rt/lib/asan/asan_thread.cpp
compiler-rt/lib/builtins/fp_compare_impl.inc
compiler-rt/lib/interception/interception.h
compiler-rt/lib/interception/interception_linux.h
compiler-rt/lib/lsan/lsan.cpp
compiler-rt/lib/lsan/lsan_allocator.cpp
compiler-rt/lib/lsan/lsan_allocator.h
compiler-rt/lib/lsan/lsan_common.cpp
compiler-rt/lib/lsan/lsan_common.h
compiler-rt/lib/lsan/lsan_common_linux.cpp
compiler-rt/lib/lsan/lsan_interceptors.cpp
compiler-rt/lib/lsan/lsan_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_linux.h
compiler-rt/lib/sanitizer_common/sanitizer_platform.h
compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
compiler-rt/lib/ubsan/ubsan_checks.inc
compiler-rt/lib/ubsan/ubsan_diag.cpp
compiler-rt/lib/ubsan/ubsan_flags.cpp
compiler-rt/lib/ubsan/ubsan_handlers.cpp
compiler-rt/lib/ubsan/ubsan_platform.h
compiler-rt/lib/ubsan/ubsan_signals_standalone.cpp
libcxx/include/__config
libcxx/include/locale
libcxx/include/typeinfo
libcxx/src/include/config_elast.h
libcxx/src/new.cpp
libcxx/src/support/runtime/exception_fallback.ipp
libcxxabi/include/cxxabi.h
libcxxabi/src/abort_message.cpp
libcxxabi/src/cxa_exception.cpp
libcxxabi/src/cxa_exception.h
libcxxabi/src/cxa_handlers.cpp
libcxxabi/src/cxa_personality.cpp
libcxxabi/src/cxa_thread_atexit.cpp
libcxxabi/src/private_typeinfo.cpp
libcxxabi/src/stdlib_new_delete.cpp

Removed: 




diff  --git a/compiler-rt/lib/asan/asan_errors.cpp 
b/compiler-rt/lib/asan/asan_errors.cpp
index a22bf130d8233..f1ccbb8f50f82 100644
--- a/compiler-rt/lib/asan/asan_errors.cpp
+++ b/compiler-rt/lib/asan/asan_errors.cpp
@@ -482,6 +482,17 @@ ErrorGeneric::ErrorGeneric(u32 tid, uptr pc_, uptr bp_, 
uptr sp_, uptr addr,
   scariness.Scare(bug_type_score + read_after_free_bonus, bug_descr);
   if (far_from_bounds) scariness.Scare(10, "far-from-bounds");
 }
+#if SANITIZER_EMSCRIPTEN
+// If address is in the first page (64 KB), then it is likely that the
+// access is a result of a null pointer dereference.
+else if (addr < 65536) {
+  bug_descr = "null-pointer-dereference";
+  scariness.Scare(25, bug_descr);
+} else if (AddrIsInShadow(addr)) {
+  bug_descr = "shadow-access";
+  scariness.Scare(25, bug_descr);
+}
+#endif
   }
 }
 

diff  --git a/compiler-rt/lib/asan/asan_flags.cpp 
b/compiler-rt/lib/asan/asan_flags.cpp
index 9ea899f84b4b7..d7ef1a109f2ee 100644
--- a/compiler-rt/lib/asan/asan_flags.cpp
+++ b/compiler-rt/lib/asan/asan_flags.cpp
@@ -22,6 +22,12 @@
 #include "ubsan/ubsan_flags.h"
 #include "ubsan/ubsan_platform.h"
 
+#if SANITIZER_EMSCRIPTEN
+extern "C" void emscripten_builtin_free(void *);
+#include 
+#endif
+
+
 namespace __asan {
 
 Flags asan_flags_dont_use_directly;  // use via flags().
@@ -54,7 +60,11 @@ void InitializeFlags() {
 CommonFlags cf;
 cf.CopyFrom(*common_flags());
 cf.detect_leaks = cf.detect_leaks && CAN_SANITIZE_LEAKS;
+#if !SANITIZER_EMSCRIPTEN
+// getenv on emscripten uses malloc, which we can't when using LSan.
+// You can't run external sym

[llvm-branch-commits] [compiler-rt] 908f8e1 - Rebase of changed from emscripten-libs-13.0.0 onto llvmorg-14.0.0

2022-09-06 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2022-09-06T02:22:35-07:00
New Revision: 908f8e197b3162cc9cae9d9e9b35bb366e7e99e1

URL: 
https://github.com/llvm/llvm-project/commit/908f8e197b3162cc9cae9d9e9b35bb366e7e99e1
DIFF: 
https://github.com/llvm/llvm-project/commit/908f8e197b3162cc9cae9d9e9b35bb366e7e99e1.diff

LOG: Rebase of changed from emscripten-libs-13.0.0 onto llvmorg-14.0.0

Added: 


Modified: 
compiler-rt/lib/asan/asan_errors.cpp
compiler-rt/lib/asan/asan_flags.cpp
compiler-rt/lib/asan/asan_globals.cpp
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp
compiler-rt/lib/asan/asan_malloc_linux.cpp
compiler-rt/lib/asan/asan_mapping.h
compiler-rt/lib/asan/asan_poisoning.cpp
compiler-rt/lib/asan/asan_poisoning.h
compiler-rt/lib/asan/asan_posix.cpp
compiler-rt/lib/asan/asan_rtl.cpp
compiler-rt/lib/asan/asan_shadow_setup.cpp
compiler-rt/lib/asan/asan_thread.cpp
compiler-rt/lib/builtins/fp_compare_impl.inc
compiler-rt/lib/interception/interception.h
compiler-rt/lib/interception/interception_linux.h
compiler-rt/lib/lsan/lsan.cpp
compiler-rt/lib/lsan/lsan_allocator.cpp
compiler-rt/lib/lsan/lsan_common.cpp
compiler-rt/lib/lsan/lsan_common.h
compiler-rt/lib/lsan/lsan_common_linux.cpp
compiler-rt/lib/lsan/lsan_interceptors.cpp
compiler-rt/lib/lsan/lsan_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_linux.h
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_platform.h
compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
compiler-rt/lib/ubsan/ubsan_checks.inc
compiler-rt/lib/ubsan/ubsan_diag.cpp
compiler-rt/lib/ubsan/ubsan_flags.cpp
compiler-rt/lib/ubsan/ubsan_handlers.cpp
compiler-rt/lib/ubsan/ubsan_platform.h
compiler-rt/lib/ubsan/ubsan_signals_standalone.cpp
libcxx/include/__config
libcxx/include/typeinfo
libcxx/src/new.cpp
libcxx/src/support/runtime/exception_fallback.ipp
libcxxabi/include/cxxabi.h
libcxxabi/src/abort_message.cpp
libcxxabi/src/cxa_exception.cpp
libcxxabi/src/cxa_exception.h
libcxxabi/src/cxa_handlers.cpp
libcxxabi/src/cxa_personality.cpp
libcxxabi/src/cxa_thread_atexit.cpp
libcxxabi/src/private_typeinfo.cpp
libcxxabi/src/stdlib_new_delete.cpp

Removed: 




diff  --git a/compiler-rt/lib/asan/asan_errors.cpp 
b/compiler-rt/lib/asan/asan_errors.cpp
index 10f7c17991d72..c5f958a453197 100644
--- a/compiler-rt/lib/asan/asan_errors.cpp
+++ b/compiler-rt/lib/asan/asan_errors.cpp
@@ -480,6 +480,17 @@ ErrorGeneric::ErrorGeneric(u32 tid, uptr pc_, uptr bp_, 
uptr sp_, uptr addr,
   scariness.Scare(bug_type_score + read_after_free_bonus, bug_descr);
   if (far_from_bounds) scariness.Scare(10, "far-from-bounds");
 }
+#if SANITIZER_EMSCRIPTEN
+// If address is in the first page (64 KB), then it is likely that the
+// access is a result of a null pointer dereference.
+else if (addr < 65536) {
+  bug_descr = "null-pointer-dereference";
+  scariness.Scare(25, bug_descr);
+} else if (AddrIsInShadow(addr)) {
+  bug_descr = "shadow-access";
+  scariness.Scare(25, bug_descr);
+}
+#endif
   }
 }
 

diff  --git a/compiler-rt/lib/asan/asan_flags.cpp 
b/compiler-rt/lib/asan/asan_flags.cpp
index 2398984332321..b1feaf903e206 100644
--- a/compiler-rt/lib/asan/asan_flags.cpp
+++ b/compiler-rt/lib/asan/asan_flags.cpp
@@ -22,6 +22,12 @@
 #include "ubsan/ubsan_flags.h"
 #include "ubsan/ubsan_platform.h"
 
+#if SANITIZER_EMSCRIPTEN
+extern "C" void emscripten_builtin_free(void *);
+#include 
+#endif
+
+
 namespace __asan {
 
 Flags asan_flags_dont_use_directly;  // use via flags().
@@ -54,7 +60,11 @@ void InitializeFlags() {
 CommonFlags cf;
 cf.CopyFrom(*common_f

[llvm-branch-commits] [libcxxabi] b88f4ab - Rebase of changed from emscripten-libs-13.0.0 onto llvmorg-14.0.0

2022-09-06 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2022-09-06T02:34:14-07:00
New Revision: b88f4ab4994e008b539522fb27bfd46fd8de9639

URL: 
https://github.com/llvm/llvm-project/commit/b88f4ab4994e008b539522fb27bfd46fd8de9639
DIFF: 
https://github.com/llvm/llvm-project/commit/b88f4ab4994e008b539522fb27bfd46fd8de9639.diff

LOG: Rebase of changed from emscripten-libs-13.0.0 onto llvmorg-14.0.0

Added: 


Modified: 
compiler-rt/lib/asan/asan_errors.cpp
compiler-rt/lib/asan/asan_flags.cpp
compiler-rt/lib/asan/asan_globals.cpp
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp
compiler-rt/lib/asan/asan_malloc_linux.cpp
compiler-rt/lib/asan/asan_mapping.h
compiler-rt/lib/asan/asan_poisoning.cpp
compiler-rt/lib/asan/asan_poisoning.h
compiler-rt/lib/asan/asan_posix.cpp
compiler-rt/lib/asan/asan_rtl.cpp
compiler-rt/lib/asan/asan_shadow_setup.cpp
compiler-rt/lib/asan/asan_thread.cpp
compiler-rt/lib/builtins/fp_compare_impl.inc
compiler-rt/lib/interception/interception.h
compiler-rt/lib/interception/interception_linux.h
compiler-rt/lib/lsan/lsan.cpp
compiler-rt/lib/lsan/lsan_allocator.cpp
compiler-rt/lib/lsan/lsan_common.cpp
compiler-rt/lib/lsan/lsan_common.h
compiler-rt/lib/lsan/lsan_common_linux.cpp
compiler-rt/lib/lsan/lsan_interceptors.cpp
compiler-rt/lib/lsan/lsan_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_linux.h
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_platform.h
compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_internal.h
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
compiler-rt/lib/sanitizer_common/sanitizer_syscall_generic.inc
compiler-rt/lib/ubsan/ubsan_checks.inc
compiler-rt/lib/ubsan/ubsan_diag.cpp
compiler-rt/lib/ubsan/ubsan_flags.cpp
compiler-rt/lib/ubsan/ubsan_handlers.cpp
compiler-rt/lib/ubsan/ubsan_platform.h
compiler-rt/lib/ubsan/ubsan_signals_standalone.cpp
libcxx/include/__config
libcxx/include/typeinfo
libcxx/src/new.cpp
libcxx/src/support/runtime/exception_fallback.ipp
libcxxabi/include/cxxabi.h
libcxxabi/src/abort_message.cpp
libcxxabi/src/cxa_exception.cpp
libcxxabi/src/cxa_exception.h
libcxxabi/src/cxa_handlers.cpp
libcxxabi/src/cxa_personality.cpp
libcxxabi/src/cxa_thread_atexit.cpp
libcxxabi/src/private_typeinfo.cpp
libcxxabi/src/stdlib_new_delete.cpp

Removed: 




diff  --git a/compiler-rt/lib/asan/asan_errors.cpp 
b/compiler-rt/lib/asan/asan_errors.cpp
index 10f7c17991d72..c5f958a453197 100644
--- a/compiler-rt/lib/asan/asan_errors.cpp
+++ b/compiler-rt/lib/asan/asan_errors.cpp
@@ -480,6 +480,17 @@ ErrorGeneric::ErrorGeneric(u32 tid, uptr pc_, uptr bp_, 
uptr sp_, uptr addr,
   scariness.Scare(bug_type_score + read_after_free_bonus, bug_descr);
   if (far_from_bounds) scariness.Scare(10, "far-from-bounds");
 }
+#if SANITIZER_EMSCRIPTEN
+// If address is in the first page (64 KB), then it is likely that the
+// access is a result of a null pointer dereference.
+else if (addr < 65536) {
+  bug_descr = "null-pointer-dereference";
+  scariness.Scare(25, bug_descr);
+} else if (AddrIsInShadow(addr)) {
+  bug_descr = "shadow-access";
+  scariness.Scare(25, bug_descr);
+}
+#endif
   }
 }
 

diff  --git a/compiler-rt/lib/asan/asan_flags.cpp 
b/compiler-rt/lib/asan/asan_flags.cpp
index 2398984332321..b1feaf903e206 100644
--- a/compiler-rt/lib/asan/asan_flags.cpp
+++ b/compiler-rt/lib/asan/asan_flags.cpp
@@ -22,6 +22,12 @@
 #include "ubsan/ubsan_flags.h"
 #include "ubsan/ubsan_platform.h"
 
+#if SANITIZER_EMSCRIPTEN
+extern "C" void emscripten_builtin_free(void *);
+#include 
+#endif
+
+
 namespace __asan {
 
 Flags asan_flags_dont_use_directly;  // use via flags().
@@ -54,7 +60,11 @@ void InitializeFlags() {
 CommonFlags cf;
 cf.CopyFrom(*common_f

[llvm-branch-commits] [llvm] dca7f08 - AMDGPU: mbcnt allow for non-zero src1 for known-bits

2022-09-06 Thread Tobias Hieta via llvm-branch-commits

Author: David Stuttard
Date: 2022-09-07T08:37:18+02:00
New Revision: dca7f087109debc1f376946dc244ed5d7e27a257

URL: 
https://github.com/llvm/llvm-project/commit/dca7f087109debc1f376946dc244ed5d7e27a257
DIFF: 
https://github.com/llvm/llvm-project/commit/dca7f087109debc1f376946dc244ed5d7e27a257.diff

LOG: AMDGPU: mbcnt allow for non-zero src1 for known-bits

Src1 for mbcnt can be a non-zero literal or register. Take this into account
when calculating known bits.

Differential Revision: https://reviews.llvm.org/D131478

(cherry picked from commit 1d1cc05539e275ae7666fc4b44bf725ec335078a)

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mbcnt.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
index bf520a5604043..c0a94cc758bb2 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
@@ -4600,9 +4600,16 @@ void AMDGPUTargetLowering::computeKnownBitsForTargetNode(
 case Intrinsic::amdgcn_mbcnt_hi: {
   const GCNSubtarget &ST =
   DAG.getMachineFunction().getSubtarget();
-  // These return at most the wavefront size - 1.
+  // These return at most the (wavefront size - 1) + src1
+  // As long as src1 is an immediate we can calc known bits
+  KnownBits Src1Known = DAG.computeKnownBits(Op.getOperand(2), Depth + 1);
+  unsigned Src1ValBits = Src1Known.countMaxActiveBits();
+  unsigned MaxActiveBits = std::max(Src1ValBits, 
ST.getWavefrontSizeLog2());
+  // Cater for potential carry
+  MaxActiveBits += Src1ValBits ? 1 : 0;
   unsigned Size = Op.getValueType().getSizeInBits();
-  Known.Zero.setHighBits(Size - ST.getWavefrontSizeLog2());
+  if (MaxActiveBits < Size)
+Known.Zero.setHighBits(Size - MaxActiveBits);
   break;
 }
 case Intrinsic::amdgcn_workitem_id_x:

diff  --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mbcnt.ll 
b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mbcnt.ll
index 04405470aff0c..88d6bea38b100 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mbcnt.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.mbcnt.ll
@@ -14,24 +14,79 @@ main_body:
   ret void
 }
 
-; GCN-LABEL: {{^}}mbcnt_lo_known_bits:
+; GCN-LABEL: {{^}}mbcnt_lo_known_bits_1:
 ; GCN: v_mbcnt_lo_u32_b32
-; GCN-NOT: and
-define i32 @mbcnt_lo_known_bits(i32 %x, i32 %y) #0 {
+; GCN: v_and_b32_e32
+define i32 @mbcnt_lo_known_bits_1(i32 %x, i32 %y) #0 {
   %lo = call i32 @llvm.amdgcn.mbcnt.lo(i32 %x, i32 %y)
   %mask = and i32 %lo, 63
   ret i32 %mask
 }
 
-; GCN-LABEL: {{^}}mbcnt_hi_known_bits:
-; GCN: v_mbcnt_hi_u32_b32
+; GCN-LABEL: {{^}}mbcnt_lo_known_bits_2:
+; GCN: v_mbcnt_lo_u32_b32
+; GCN-NOT: and
+define i32 @mbcnt_lo_known_bits_2(i32 %x) #0 {
+  %lo = call i32 @llvm.amdgcn.mbcnt.lo(i32 %x, i32 0)
+  %mask = and i32 %lo, 63
+  ret i32 %mask
+}
+
+; GCN-LABEL: {{^}}mbcnt_lo_known_bits_3:
+; GCN: v_mbcnt_lo_u32_b32
 ; GCN-NOT: and
-define i32 @mbcnt_hi_known_bits(i32 %x, i32 %y) #0 {
+define i32 @mbcnt_lo_known_bits_3(i32 %x) #0 {
+  %lo = call i32 @llvm.amdgcn.mbcnt.lo(i32 %x, i32 15)
+  %mask = and i32 %lo, 127
+  ret i32 %mask
+}
+
+; GCN-LABEL: {{^}}mbcnt_lo_known_bits_4:
+; GCN: v_mbcnt_lo_u32_b32
+; GCN: v_and_b32_e32
+define i32 @mbcnt_lo_known_bits_4(i32 %x) #0 {
+  %lo = call i32 @llvm.amdgcn.mbcnt.lo(i32 %x, i32 15)
+  %mask = and i32 %lo, 63
+  ret i32 %mask
+}
+
+
+; GCN-LABEL: {{^}}mbcnt_hi_known_bits_1:
+; GCN: v_mbcnt_hi_u32_b32
+; GCN: v_and_b32_e32
+define i32 @mbcnt_hi_known_bits_1(i32 %x, i32 %y) #0 {
   %hi = call i32 @llvm.amdgcn.mbcnt.hi(i32 %x, i32 %y)
   %mask = and i32 %hi, 63
   ret i32 %mask
 }
 
+; GCN-LABEL: {{^}}mbcnt_hi_known_bits_2:
+; GCN: v_mbcnt_hi_u32_b32
+; GCN-NOT: and
+define i32 @mbcnt_hi_known_bits_2(i32 %x) #0 {
+  %hi = call i32 @llvm.amdgcn.mbcnt.hi(i32 %x, i32 0)
+  %mask = and i32 %hi, 63
+  ret i32 %mask
+}
+
+; GCN-LABEL: {{^}}mbcnt_hi_known_bits_3:
+; GCN: v_mbcnt_hi_u32_b32
+; GCN-NOT: and
+define i32 @mbcnt_hi_known_bits_3(i32 %x) #0 {
+  %hi = call i32 @llvm.amdgcn.mbcnt.hi(i32 %x, i32 15)
+  %mask = and i32 %hi, 127
+  ret i32 %mask
+}
+
+; GCN-LABEL: {{^}}mbcnt_hi_known_bits_4:
+; GCN: v_mbcnt_hi_u32_b32
+; GCN: v_and_b32_e32
+define i32 @mbcnt_hi_known_bits_4(i32 %x) #0 {
+  %hi = call i32 @llvm.amdgcn.mbcnt.hi(i32 %x, i32 15)
+  %mask = and i32 %hi, 63
+  ret i32 %mask
+}
+
 declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #0
 declare i32 @llvm.amdgcn.mbcnt.hi(i32, i32) #0
 declare void @llvm.amdgcn.exp.f32(i32, i32, float, float, float, float, i1, 
i1) #1



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 8f820dd - [Symbolizer] Implement data symbolizer markup element.

2022-09-06 Thread Tobias Hieta via llvm-branch-commits

Author: Daniel Thornburgh
Date: 2022-09-07T08:37:30+02:00
New Revision: 8f820dd89e9b27523db809ad8e205d4b0ddbf284

URL: 
https://github.com/llvm/llvm-project/commit/8f820dd89e9b27523db809ad8e205d4b0ddbf284
DIFF: 
https://github.com/llvm/llvm-project/commit/8f820dd89e9b27523db809ad8e205d4b0ddbf284.diff

LOG: [Symbolizer] Implement data symbolizer markup element.

This connects the Symbolizer to the markup filter and enables the first
working end-to-end flow using the filter.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D130187

(cherry picked from commit 22df238d4a642a4553ebf7b91325189be48b139d)

Added: 
llvm/test/DebugInfo/symbolize-filter-markup-data.test

Modified: 
llvm/docs/CommandGuide/llvm-symbolizer.rst
llvm/docs/SymbolizerMarkupFormat.rst
llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
llvm/test/DebugInfo/symbolize-filter-markup-context-line-elision.test
llvm/test/DebugInfo/symbolize-filter-markup-error-location.test
llvm/test/DebugInfo/symbolize-filter-markup-mmap.test
llvm/test/DebugInfo/symbolize-filter-markup-module.test
llvm/test/DebugInfo/symbolize-filter-markup-reset.test
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp

Removed: 




diff  --git a/llvm/docs/CommandGuide/llvm-symbolizer.rst 
b/llvm/docs/CommandGuide/llvm-symbolizer.rst
index 33b5fa5b0fe1a..3fff88a7f1651 100644
--- a/llvm/docs/CommandGuide/llvm-symbolizer.rst
+++ b/llvm/docs/CommandGuide/llvm-symbolizer.rst
@@ -251,13 +251,13 @@ OPTIONS
 
   Reads from standard input, converts contained
   :doc:`Symbolizer Markup ` into human-readable form,
-  and prints the results to standard output. Presently, only the following
-  markup elements are supported:
+  and prints the results to standard output. The following markup elements are
+  not yet supported:
 
-  * ``{{symbol}}``
-  * ``{{reset}}``
-  * ``{{module}}``
-  * ``{{mmap}}``
+  * ``{{pc}}``
+  * ``{{bt}}``
+  * ``{{hexdict}}``
+  * ``{{dumpfile}}``
 
 .. _llvm-symbolizer-opt-f:
 

diff  --git a/llvm/docs/SymbolizerMarkupFormat.rst 
b/llvm/docs/SymbolizerMarkupFormat.rst
index 95ac5d89d84e7..319a330219506 100644
--- a/llvm/docs/SymbolizerMarkupFormat.rst
+++ b/llvm/docs/SymbolizerMarkupFormat.rst
@@ -195,7 +195,7 @@ human-readable symbolic form.
 {{{pc:0x12345678}}}
 {{{pc:0x9abcdef0}}}
 
-``{{{data:%p}}}`` [#not_yet_implemented]_
+``{{{data:%p}}}``
 
   Here ``%p`` is the memory address of a data location. It might be presented 
as
   the name of a global variable at that location.

diff  --git a/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h 
b/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
index 26686143af95b..3a2c2bf490411 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
@@ -26,11 +26,14 @@
 namespace llvm {
 namespace symbolize {
 
+class LLVMSymbolizer;
+
 /// Filter to convert parsed log symbolizer markup elements into human-readable
 /// text.
 class MarkupFilter {
 public:
-  MarkupFilter(raw_ostream &OS, Optional ColorsEnabled = llvm::None);
+  MarkupFilter(raw_ostream &OS, LLVMSymbolizer &Symbolizer,
+   Optional ColorsEnabled = llvm::None);
 
   /// Filters a line containing symbolizer markup and writes the human-readable
   /// results to the output stream.
@@ -57,6 +60,7 @@ class MarkupFilter {
 uint64_t ModuleRelativeAddr;
 
 bool contains(uint64_t Addr) const;
+uint64_t getModuleRelativeAddr(uint64_t Addr) const;
   };
 
   // An informational module line currently being constructed. As many mmap
@@ -83,6 +87,7 @@ class MarkupFilter {
 
   bool tryPresentation(const MarkupNode &Node);
   bool trySymbol(const MarkupNode &Node);
+  bool tryData(const MarkupNode &Node);
 
   bool trySGR(const MarkupNode &Node);
 
@@ -107,11 +112,13 @@ class MarkupFilter {
   void reportTypeError(StringRef Str, StringRef TypeName) const;
   void reportLocation(StringRef::iterator Loc) const;
 
-  const MMap *overlappingMMap(const MMap &Map) const;
+  const MMap *getOverlappingMMap(const MMap &Map) const;
+  const MMap *getContainingMMap(uint64_t Addr) const;
 
   StringRef lineEnding() const;
 
   raw_ostream &OS;
+  LLVMSymbolizer &Symbolizer;
   const bool ColorsEnabled;
 
   MarkupParser Parser;

diff  --git a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp 
b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
index 91a51485026e0..2bf2e17514e1d 100644
--- a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
@@ -21,6 +21,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/DebugInfo/Symbolize/Markup.h"
+#include "llvm/DebugInfo/Symbolize/Symbolize.h"
 #include "llvm/Debuginfod/Debuginfod.h"
 #include "llvm/Demangle/Demangle.h"
 #include "llvm/Object/ObjectFile.h"
@@ -32,9

[llvm-branch-commits] [llvm] 55b8f29 - [Symbolizer] Fix symbolizer-filter-markup-pc.test on Windows

2022-09-06 Thread Tobias Hieta via llvm-branch-commits

Author: Daniel Thornburgh
Date: 2022-09-07T08:37:30+02:00
New Revision: 55b8f29a9c4c131b744d4e705e1dfa9bb6ff8459

URL: 
https://github.com/llvm/llvm-project/commit/55b8f29a9c4c131b744d4e705e1dfa9bb6ff8459
DIFF: 
https://github.com/llvm/llvm-project/commit/55b8f29a9c4c131b744d4e705e1dfa9bb6ff8459.diff

LOG: [Symbolizer] Fix symbolizer-filter-markup-pc.test on Windows

(cherry picked from commit 0d6cf1e8b5fa8590f816d5330cb7c2dcc449ec24)

Added: 


Modified: 
llvm/test/DebugInfo/symbolize-filter-markup-pc.test

Removed: 




diff  --git a/llvm/test/DebugInfo/symbolize-filter-markup-pc.test 
b/llvm/test/DebugInfo/symbolize-filter-markup-pc.test
index 5d77a5c72411..19b5e5be0d37 100644
--- a/llvm/test/DebugInfo/symbolize-filter-markup-pc.test
+++ b/llvm/test/DebugInfo/symbolize-filter-markup-pc.test
@@ -10,10 +10,10 @@ RUN:   --implicit-check-not {{.}}
 RUN: FileCheck %s --check-prefix=ERR --input-file=%t.err --match-full-lines
 
 CHECK: [[BEGIN:\[{3}]]ELF module #0x0 "a.o"; BuildID=abcdef 
[0x0-0xff](r)[[END:\]{3}]]
-CHECK: first[/dir/tmp.c:3]
-CHECK: first[/dir/tmp.c:5]
-CHECK: first[/dir/tmp.c:4]
-CHECK: first[/dir/tmp.c:5]
+CHECK: first[/dir[[SEP:[/\\]]]tmp.c:3]
+CHECK: first[/dir[[SEP]]tmp.c:5]
+CHECK: first[/dir[[SEP]]tmp.c:4]
+CHECK: first[/dir[[SEP]]tmp.c:5]
 CHECK: [[BEGIN]]pc:0xff[[END]]
 CHECK: [[BEGIN]]pc:0x100[[END]]
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 4cc81e3 - [Symbolizer] Implement pc element in symbolizing filter.

2022-09-06 Thread Tobias Hieta via llvm-branch-commits

Author: Daniel Thornburgh
Date: 2022-09-07T08:37:30+02:00
New Revision: 4cc81e378a857ffcfdca3d654d3345b9ea9ab05f

URL: 
https://github.com/llvm/llvm-project/commit/4cc81e378a857ffcfdca3d654d3345b9ea9ab05f
DIFF: 
https://github.com/llvm/llvm-project/commit/4cc81e378a857ffcfdca3d654d3345b9ea9ab05f.diff

LOG: [Symbolizer] Implement pc element in symbolizing filter.

Implements the pc element for the symbolizing filter, including it's
"ra" and "pc" modes. Return addresses ("ra") are adjusted by
decrementing one. By default, {{{pc}}} elements are assumed to point to
precise code ("pc") locations. Backtrace elements will adopt the
opposite convention.

Along the way, some minor refactors of value printing and colorization.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D131115

(cherry picked from commit bf48b128b02813e53e0c8f6585db837d14c9358f)

Added: 
llvm/test/DebugInfo/symbolize-filter-markup-pc.test

Modified: 
llvm/docs/CommandGuide/llvm-symbolizer.rst
llvm/docs/SymbolizerMarkupFormat.rst
llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
llvm/test/DebugInfo/symbolize-filter-markup-data.test

Removed: 




diff  --git a/llvm/docs/CommandGuide/llvm-symbolizer.rst 
b/llvm/docs/CommandGuide/llvm-symbolizer.rst
index 3fff88a7f1651..5870e0e9e95e6 100644
--- a/llvm/docs/CommandGuide/llvm-symbolizer.rst
+++ b/llvm/docs/CommandGuide/llvm-symbolizer.rst
@@ -254,7 +254,6 @@ OPTIONS
   and prints the results to standard output. The following markup elements are
   not yet supported:
 
-  * ``{{pc}}``
   * ``{{bt}}``
   * ``{{hexdict}}``
   * ``{{dumpfile}}``

diff  --git a/llvm/docs/SymbolizerMarkupFormat.rst 
b/llvm/docs/SymbolizerMarkupFormat.rst
index 319a330219506..b06cc20f41ef4 100644
--- a/llvm/docs/SymbolizerMarkupFormat.rst
+++ b/llvm/docs/SymbolizerMarkupFormat.rst
@@ -184,7 +184,7 @@ human-readable symbolic form.
 {{{symbol:_ZN7Mangled4NameEv}}}
 {{{symbol:foobar}}}
 
-``{{{pc:%p}}}``, ``{{{pc:%p:ra}}}``, ``{{{pc:%p:pc}}}`` [#not_yet_implemented]_
+``{{{pc:%p}}}``, ``{{{pc:%p:ra}}}``, ``{{{pc:%p:pc}}}``
 
   Here ``%p`` is the memory address of a code location. It might be presented 
as a
   function name and source location. The second two forms distinguish the kind 
of

diff  --git a/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h 
b/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
index 3a2c2bf490411..b597e9ba7ba25 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
@@ -71,6 +71,15 @@ class MarkupFilter {
 SmallVector MMaps = {};
   };
 
+  // The semantics of a possible program counter value.
+  enum class PCType {
+// The address is a return address and must be adjusted to point to the 
call
+// itself.
+ReturnAddress,
+// The address is the precise location in the code and needs no adjustment.
+PreciseCode,
+  };
+
   bool tryContextualElement(const MarkupNode &Node,
 const SmallVector &DeferredNodes);
   bool tryMMap(const MarkupNode &Element,
@@ -87,6 +96,7 @@ class MarkupFilter {
 
   bool tryPresentation(const MarkupNode &Node);
   bool trySymbol(const MarkupNode &Node);
+  bool tryPC(const MarkupNode &Node);
   bool tryData(const MarkupNode &Node);
 
   bool trySGR(const MarkupNode &Node);
@@ -96,6 +106,9 @@ class MarkupFilter {
   void restoreColor();
   void resetColor();
 
+  void printRawElement(const MarkupNode &Element);
+  void printValue(Twine Value);
+
   Optional parseModule(const MarkupNode &Element) const;
   Optional parseMMap(const MarkupNode &Element) const;
 
@@ -104,10 +117,12 @@ class MarkupFilter {
   Optional parseSize(StringRef Str) const;
   Optional> parseBuildID(StringRef Str) const;
   Optional parseMode(StringRef Str) const;
+  Optional parsePCType(StringRef Str) const;
 
   bool checkTag(const MarkupNode &Node) const;
   bool checkNumFields(const MarkupNode &Element, size_t Size) const;
   bool checkNumFieldsAtLeast(const MarkupNode &Element, size_t Size) const;
+  bool checkNumFieldsAtMost(const MarkupNode &Element, size_t Size) const;
 
   void reportTypeError(StringRef Str, StringRef TypeName) const;
   void reportLocation(StringRef::iterator Loc) const;
@@ -115,6 +130,8 @@ class MarkupFilter {
   const MMap *getOverlappingMMap(const MMap &Map) const;
   const MMap *getContainingMMap(uint64_t Addr) const;
 
+  uint64_t adjustAddr(uint64_t Addr, PCType Type) const;
+
   StringRef lineEnding() const;
 
   raw_ostream &OS;

diff  --git a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp 
b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
index 2bf2e17514e1d..70fb49d74b3a1 100644
--- a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/Stri

[llvm-branch-commits] [llvm] 7ce1ec5 - [Symbolizer] Handle {{{bt}}} symbolizer markup element.

2022-09-06 Thread Tobias Hieta via llvm-branch-commits

Author: Daniel Thornburgh
Date: 2022-09-07T08:37:30+02:00
New Revision: 7ce1ec5a2a22fec588bd5f87a50052a97f7dd846

URL: 
https://github.com/llvm/llvm-project/commit/7ce1ec5a2a22fec588bd5f87a50052a97f7dd846
DIFF: 
https://github.com/llvm/llvm-project/commit/7ce1ec5a2a22fec588bd5f87a50052a97f7dd846.diff

LOG: [Symbolizer] Handle {{{bt}}} symbolizer markup element.

This adds support for backtrace generation to the llvm-symbolizer markup
filter, which is likely the largest use case.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D132706

(cherry picked from commit ea99225521cba6dec1ad4ca70a8665829e772fa9)

Added: 
llvm/test/DebugInfo/symbolize-filter-markup-bt.test

Modified: 
llvm/docs/CommandGuide/llvm-symbolizer.rst
llvm/docs/SymbolizerMarkupFormat.rst
llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp

Removed: 




diff  --git a/llvm/docs/CommandGuide/llvm-symbolizer.rst 
b/llvm/docs/CommandGuide/llvm-symbolizer.rst
index 5870e0e9e95e6..abb174c7579ee 100644
--- a/llvm/docs/CommandGuide/llvm-symbolizer.rst
+++ b/llvm/docs/CommandGuide/llvm-symbolizer.rst
@@ -254,9 +254,21 @@ OPTIONS
   and prints the results to standard output. The following markup elements are
   not yet supported:
 
-  * ``{{bt}}``
-  * ``{{hexdict}}``
-  * ``{{dumpfile}}``
+  * ``{{{hexdict}}}``
+  * ``{{{dumpfile}}}``
+
+  The ``{{{bt}}}`` backtrace element reports frames using the following syntax:
+
+  ``#[.]   :: 
(+)``
+
+   provides frame numbers for calls inlined into the caller
+  coresponding to . The inlined call numbers start at 1 and 
increase
+  from callee to caller.
+
+   is an address inside the call instruction to the function.  The
+  address may not be the start of the instruction.   is
+  the corresponding virtual offset in the  loaded at that address.
+
 
 .. _llvm-symbolizer-opt-f:
 

diff  --git a/llvm/docs/SymbolizerMarkupFormat.rst 
b/llvm/docs/SymbolizerMarkupFormat.rst
index b06cc20f41ef4..169e57a3aa8a9 100644
--- a/llvm/docs/SymbolizerMarkupFormat.rst
+++ b/llvm/docs/SymbolizerMarkupFormat.rst
@@ -205,7 +205,7 @@ human-readable symbolic form.
 {{{data:0x12345678}}}
 {{{data:0x9abcdef0}}}
 
-``{{{bt:%u:%p}}}``, ``{{{bt:%u:%p:ra}}}``, ``{{{bt:%u:%p:pc}}}`` 
[#not_yet_implemented]_
+``{{{bt:%u:%p}}}``, ``{{{bt:%u:%p:ra}}}``, ``{{{bt:%u:%p:pc}}}``
 
   This represents one frame in a backtrace. It usually appears on a line by
   itself (surrounded only by whitespace), in a sequence of such lines with

diff  --git a/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h 
b/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
index b597e9ba7ba25..a54f8f5d2db81 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h
@@ -97,6 +97,7 @@ class MarkupFilter {
   bool tryPresentation(const MarkupNode &Node);
   bool trySymbol(const MarkupNode &Node);
   bool tryPC(const MarkupNode &Node);
+  bool tryBackTrace(const MarkupNode &Node);
   bool tryData(const MarkupNode &Node);
 
   bool trySGR(const MarkupNode &Node);
@@ -118,6 +119,7 @@ class MarkupFilter {
   Optional> parseBuildID(StringRef Str) const;
   Optional parseMode(StringRef Str) const;
   Optional parsePCType(StringRef Str) const;
+  Optional parseFrameNumber(StringRef Str) const;
 
   bool checkTag(const MarkupNode &Node) const;
   bool checkNumFields(const MarkupNode &Element, size_t Size) const;

diff  --git a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp 
b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
index 70fb49d74b3a1..d96c0c85d5bd1 100644
--- a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Demangle/Demangle.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
@@ -216,6 +217,8 @@ bool MarkupFilter::tryPresentation(const MarkupNode &Node) {
 return true;
   if (tryPC(Node))
 return true;
+  if (tryBackTrace(Node))
+return true;
   return tryData(Node);
 }
 
@@ -269,8 +272,7 @@ bool MarkupFilter::tryPC(const MarkupNode &Node) {
 printRawElement(Node);
 return true;
   }
-  if (LI->FileName == DILineInfo::BadString &&
-  LI->FunctionName == DILineInfo::BadString && LI->Line == 0) {
+  if (!*LI) {
 printRawElement(Node);
 return true;
   }
@@ -286,6 +288,87 @@ bool MarkupFilter::tryPC(const MarkupNode &Node) {
   return true;
 }
 
+bool MarkupFilter::tryBackTrace(const MarkupNode &Node) {
+  if (Node.Tag != "bt")
+return false;
+  if (!checkNumFieldsAtLeast(Node, 2))
+return true;
+  if (!checkNumFieldsAtMost(Node, 3))
+return true;
+
+  Optional FrameNumber = parseFrameNumber(Node.Fi