[compiler-rt] [rtsan] Only print out unique stack traces (PR #110028)

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 25 17:21:47 PDT 2024


================
@@ -49,7 +50,21 @@ static auto OnViolationAction(DiagnosticsInfo info) {
   return [info]() {
     IncrementTotalErrorCount();
 
-    PrintDiagnostics(info);
+    BufferedStackTrace stack;
+    stack.Unwind(info.pc, info.bp, nullptr,
+                 /*request_fast*/ true);
+
+    StackDepotHandle handle = StackDepotPut_WithHandle(stack);
+
+    const bool is_stack_novel = handle.use_count() == 0;
+    if (UNLIKELY(is_stack_novel)) {
----------------
ilovepi wrote:

If you really want to know, you can profile the runtime and use MisExpect to vet how accurate your guess was. 
https://clang.llvm.org/docs/MisExpect.html

Also, FWIW, we typically see `__builtin_expect_with_probability` do better on performance metrics than `__builtin_expect`. 

https://github.com/llvm/llvm-project/pull/110028


More information about the llvm-commits mailing list