[compiler-rt] r355370 - [NFC] Move asan_inited and size reset on top of ::UnwindImpl

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 18:50:49 PST 2019


Author: vitalybuka
Date: Mon Mar  4 18:50:49 2019
New Revision: 355370

URL: http://llvm.org/viewvc/llvm-project?rev=355370&view=rev
Log:
[NFC] Move asan_inited and size reset on top of  ::UnwindImpl

Modified:
    compiler-rt/trunk/lib/asan/asan_stack.cc

Modified: compiler-rt/trunk/lib/asan/asan_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_stack.cc?rev=355370&r1=355369&r2=355370&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_stack.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_stack.cc Mon Mar  4 18:50:49 2019
@@ -31,26 +31,26 @@ u32 GetMallocContextSize() {
 void __sanitizer::BufferedStackTrace::UnwindImpl(
     uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) {
   using namespace __asan;
+  size = 0;
+  if (UNLIKELY(!asan_inited))
+    return;
 #if SANITIZER_WINDOWS
   Unwind(max_depth, pc, 0, context, 0, 0, false);
 #else
-  AsanThread *t;
-  size = 0;
-  if (LIKELY(asan_inited)) {
-    if ((t = GetCurrentThread()) && !t->isUnwinding()) {
-      uptr stack_top = t->stack_top();
-      uptr stack_bottom = t->stack_bottom();
-      ScopedUnwinding unwind_scope(t);
-      if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) {
-        if (StackTrace::WillUseFastUnwind(request_fast))
-          Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true);
-        else
-          Unwind(max_depth, pc, 0, context, 0, 0, false);
-      }
-    } else if (!t && !request_fast) {
-      /* If GetCurrentThread() has failed, try to do slow unwind anyways. */
-      Unwind(max_depth, pc, bp, context, 0, 0, false);
+  AsanThread *t = GetCurrentThread();
+  if (t && !t->isUnwinding()) {
+    uptr stack_top = t->stack_top();
+    uptr stack_bottom = t->stack_bottom();
+    ScopedUnwinding unwind_scope(t);
+    if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) {
+      if (StackTrace::WillUseFastUnwind(request_fast))
+        Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true);
+      else
+        Unwind(max_depth, pc, 0, context, 0, 0, false);
     }
+  } else if (!t && !request_fast) {
+    /* If GetCurrentThread() has failed, try to do slow unwind anyways. */
+    Unwind(max_depth, pc, bp, context, 0, 0, false);
   }
 #endif // SANITIZER_WINDOWS
 }




More information about the llvm-commits mailing list