[PATCH] D19148: Always inlining PrintCurrentStackSlow of tsan library to fix tail-call issue

Chuang-Yu Cheng via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 01:12:28 PDT 2016


cycheng updated this revision to Diff 54325.
cycheng added a comment.

Add test case to check whether PrintCurrentStackSlow is inlined as our expectation.


http://reviews.llvm.org/D19148

Files:
  lib/tsan/rtl/tsan_rtl_report.cc
  test/tsan/print_stack_trace.cc

Index: test/tsan/print_stack_trace.cc
===================================================================
--- /dev/null
+++ test/tsan/print_stack_trace.cc
@@ -0,0 +1,13 @@
+// RUN: %clang_tsan -O0 %s -o %t && llvm-objdump -d %run %t | FileCheck %s
+extern "C" {
+void __sanitizer_print_stack_trace();
+}
+
+int main() {
+  __sanitizer_print_stack_trace();
+  return 0;
+}
+
+// We always inline PrintCurrentStackSlow, so we shouldn't found that string in
+// executable file.
+// CHECK-NOT: PrintCurrentStackSlow
Index: lib/tsan/rtl/tsan_rtl_report.cc
===================================================================
--- lib/tsan/rtl/tsan_rtl_report.cc
+++ lib/tsan/rtl/tsan_rtl_report.cc
@@ -680,6 +680,12 @@
   PrintStack(SymbolizeStack(trace));
 }
 
+// Always inlining PrintCurrentStackSlow, because LocatePcInTrace assumes
+// __sanitizer_print_stack_trace exists in the actual unwinded stack, but
+// tail-call to PrintCurrentStackSlow breaks this assumption because
+// __sanitizer_print_stack_trace disappears after tail-call.
+// See PR27280 comment 1~3 for examples.
+ALWAYS_INLINE
 void PrintCurrentStackSlow(uptr pc) {
 #ifndef SANITIZER_GO
   BufferedStackTrace *ptrace =


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19148.54325.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160420/91f6f603/attachment.bin>


More information about the llvm-commits mailing list