diff --git a/kotlin-native/runtime/src/main/cpp/Common.h b/kotlin-native/runtime/src/main/cpp/Common.h index d931e9e2b2c..7b3aded7b0a 100644 --- a/kotlin-native/runtime/src/main/cpp/Common.h +++ b/kotlin-native/runtime/src/main/cpp/Common.h @@ -30,6 +30,8 @@ #define NO_EXTERNAL_CALLS_CHECK __attribute__((annotate("no_external_calls_check"))) +#define OPTNONE __attribute__((optnone)) + #if KONAN_NO_THREADS #define THREAD_LOCAL_VARIABLE #else diff --git a/kotlin-native/runtime/src/main/cpp/StackTraceTest.cpp b/kotlin-native/runtime/src/main/cpp/StackTraceTest.cpp index 1daa6cbcb93..cafcbc5538d 100644 --- a/kotlin-native/runtime/src/main/cpp/StackTraceTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/StackTraceTest.cpp @@ -20,24 +20,24 @@ using namespace kotlin; namespace { +// Disable optimizations for these functions to avoid inlining and tail recursion optimization. template -NO_INLINE StackTrace GetStackTrace1(size_t skipFrames = 0) { +OPTNONE StackTrace GetStackTrace1(size_t skipFrames = 0) { return StackTrace::current(skipFrames); } template -NO_INLINE StackTrace GetStackTrace2(size_t skipFrames = 0) { +OPTNONE StackTrace GetStackTrace2(size_t skipFrames = 0) { return GetStackTrace1(skipFrames); } template -NO_INLINE StackTrace GetStackTrace3(size_t skipFrames = 0) { +OPTNONE StackTrace GetStackTrace3(size_t skipFrames = 0) { return GetStackTrace2(skipFrames); } -// Disable optimizations for these functions to avoid inlining and tail recursion optimization. template -[[clang::optnone]] StackTrace GetDeepStackTrace(size_t depth) { +OPTNONE StackTrace GetDeepStackTrace(size_t depth) { if (depth <= 1) { return StackTrace::current(); } else {