llvm / llvm/llvm-project

The -fstack-usage option incorrectly calculate size of the stack used by a function

Open
#173,158 10 comments 0 reactions 0 assignees View on GitHub
diverges-from:gcc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

When calculating the size of the stack used by a function, the size of the stack does not include the size of the return address from the function. When compiling a file with any type of optimization, the size of the used stack becomes equal to 0, although it cannot be less than the return address.

```
size_test.cpp:3:_Z15simple_functionv 0 static
size_test.cpp:8:_Z16complex_functioni 0 static
size_test.cpp:17:_Z9factoriali 0 static
size_test.cpp:22:main 0 static
```

File su generated by GCC:
```
size_test.cpp:3:6:void simple_function() 8 static
size_test.cpp:8:6:void complex_function(int) 8 static
size_test.cpp:17:5:int factorial(int) 8 static
size_test.cpp:22:5:int main() 8 static
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.