diff --git a/explorer/interpreter/stack_space.cpp b/explorer/interpreter/stack_space.cpp index a1597012f3e2..3b87f54c378d 100644 --- a/explorer/interpreter/stack_space.cpp +++ b/explorer/interpreter/stack_space.cpp @@ -16,10 +16,15 @@ static constexpr int64_t DesiredStackSpace = 8 << 20; static LLVM_THREAD_LOCAL intptr_t bottom_of_stack = 0; // Returns the current bottom of stack. -static auto GetStackPointer() -> intptr_t { +LLVM_NO_SANITIZE("address") +LLVM_ATTRIBUTE_NOINLINE static auto GetStackPointer() -> intptr_t { +#if __GNUC__ || __has_builtin(__builtin_frame_address) + return reinterpret_cast(__builtin_frame_address(0)); +#else char char_on_stack = 0; char* volatile ptr = &char_on_stack; return reinterpret_cast(ptr); +#endif } auto IsStackSpaceNearlyExhausted() -> bool {