[compiler-rt] r308652 - [compiler-rt] Reorder functions to shrink stack frames

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 11:47:01 PDT 2017


Author: vitalybuka
Date: Thu Jul 20 11:47:01 2017
New Revision: 308652

URL: http://llvm.org/viewvc/llvm-project?rev=308652&view=rev
Log:
[compiler-rt] Reorder functions to shrink stack frames

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc?rev=308652&r1=308651&r2=308652&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc Thu Jul 20 11:47:01 2017
@@ -229,19 +229,14 @@ static void CallPrintfAndReportCallback(
     PrintfAndReportCallback(str);
 }
 
-static void SharedPrintfCode(bool append_pid, const char *format,
-                             va_list args) {
+static void SharedPrintfCodeNoBuffer(bool append_pid, char *local_buffer,
+                                     int buffer_size, const char *format,
+                                     va_list args) {
   va_list args2;
   va_copy(args2, args);
   const int kLen = 16 * 1024;
-  // |local_buffer| is small enough not to overflow the stack and/or violate
-  // the stack limit enforced by TSan (-Wframe-larger-than=512). On the other
-  // hand, the bigger the buffer is, the more the chance the error report will
-  // fit into it.
-  char local_buffer[400];
   int needed_length;
   char *buffer = local_buffer;
-  int buffer_size = ARRAY_SIZE(local_buffer);
   // First try to print a message using a local buffer, and then fall back to
   // mmaped buffer.
   for (int use_mmap = 0; use_mmap < 2; use_mmap++) {
@@ -291,6 +286,17 @@ static void SharedPrintfCode(bool append
   va_end(args2);
 }
 
+static void SharedPrintfCode(bool append_pid, const char *format,
+                             va_list args) {
+  // |local_buffer| is small enough not to overflow the stack and/or violate
+  // the stack limit enforced by TSan (-Wframe-larger-than=512). On the other
+  // hand, the bigger the buffer is, the more the chance the error report will
+  // fit into it.
+  char local_buffer[400];
+  SharedPrintfCodeNoBuffer(append_pid, local_buffer, ARRAY_SIZE(local_buffer),
+                           format, args);
+}
+
 FORMAT(1, 2)
 void Printf(const char *format, ...) {
   va_list args;




More information about the llvm-commits mailing list