10#include "llvm/Config/config.h"
14# include <sys/resource.h>
21#ifndef LLVM_HAS_SPLIT_STACKS
28#if __GNUC__ || __has_builtin(__builtin_frame_address)
29 return (uintptr_t)__builtin_frame_address(0);
30#elif defined(_MSC_VER)
31 return (uintptr_t)_AddressOfReturnAddress();
33 volatile char CharOnStack = 0;
39 char *
volatile Ptr = &CharOnStack;
40 return (uintptr_t)
Ptr;
47 getrlimit(RLIMIT_STACK, &RL);
59#ifdef LLVM_HAS_SPLIT_STACKS_AARCH64
60void runOnNewStackImpl(
void *Stack,
void (*Fn)(
void *),
void *Ctx) __asm__(
61 "_ZN4llvm17runOnNewStackImplEPvPFvS0_ES0_");
69 ".globl _ZN4llvm17runOnNewStackImplEPvPFvS0_ES0_\n\t"
71 "_ZN4llvm17runOnNewStackImplEPvPFvS0_ES0_:\n\t"
74 "sub x0, x0, #0x20\n\t"
75 "stp xzr, x16, [x0, #0x00]\n\t"
76 "stp x29, x30, [x0, #0x10]\n\t"
78 "add x29, x0, #0x10\n\t"
79 ".cfi_def_cfa w29, 16\n\t"
80 ".cfi_offset w30, -8\n\t"
81 ".cfi_offset w29, -16\n\t"
86 "ldp x29, x30, [sp, #0x10]\n\t"
87 "ldp xzr, x16, [sp, #0x00]\n\t"
96#ifdef LLVM_HAS_SPLIT_STACKS
103#ifdef LLVM_HAS_SPLIT_STACKS
114 void *
Stack = malloc(StackSize);
115 void *BottomOfStack = (
char *)Stack + StackSize;
117 runOnNewStackImpl(BottomOfStack, callback, &Fn);
124 StackSize == 0 ? std::nullopt : std::optional<unsigned>(StackSize), Fn);
An efficient, type-erasing, non-owning reference to a callable.
cb< typename detail::callback_traits< F >::result_type, typename detail::callback_traits< F >::arg_type > callback(F CB)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void runOnNewStack(unsigned StackSize, function_ref< void()> Fn)
Runs Fn on a new stack of at least the given size.
LLVM_ABI unsigned getDefaultStackSize()
LLVM_ABI uintptr_t getStackPointer()