Displaying 3 results from an estimated 3 matches for "stacksafe".
2017 Jul 25
2
why is llvm.stacksave() necessary?
...of the
currently executing function, to be automatically released when this
function returns to its caller.
when using come c code like
void myfunc(void){
int i=4;
double d[i];
}
the ir shows enclosing llvm.stackSave & restore constructs, enclosing
the alloca related to 'd'.
thellvm.stacksafe reference explains:
This intrinsic is used to remember the current state of the function
stack...
In practice, this pops any alloca blocks from the stack that were
allocated after the llvm.stacksave was executed.
shouldn't the alloca block related to 'd' be automatically released when...
2017 Jul 25
2
why is llvm.stacksave() necessary?
...go), where using a VLA in the form from my example would consume stack space in proportion to the sum of all values of i, rather than in proportion to the maximum value of i.
>
> David
The 'scope'in should be related to the block in IR - not?
This would then be easy: just insert a stackSafe right infront of the
alloca (as you suggested) and a restore at the end of the block...
Alex
2017 Jul 25
2
why is llvm.stacksave() necessary?
> Clang does this because clang intentionally generates IR naïvely and relies on LLVM optimisation passes to clean it up.
>
> In the case of C VLAs, the size of the alloca changes whenever the declaration goes into scope. By emitting a stack save and restore for d, clang doesn’t need to have different IR generating code for your example and for this one:
>
> void myfunc(void
>