Inada Naoki <songofaca...@gmail.com> added the comment:

FWIW, it seems -O0 don't merge local variables in different path or lifetime.

For example, see _Py_abspath

```
    if (path[0] == '\0' || !wcscmp(path, L".")) {
       wchar_t cwd[MAXPATHLEN + 1];
       //(snip)
    }
    //(snip)
    wchar_t cwd[MAXPATHLEN + 1];
```

wchar_t is 4bytes and MAXPATHLEN is 4096 on Linux. So each cwd is 16388bytes.
-Og allocates 32856 bytes for it and -Og allocates 16440 bytes for it.

I don't know what is the specific optimization flag in -Og do merge local 
variable, but I think -Og is very important for _PyEval_EvalFrameDefault() 
since it has many local variables in huge switch-case statements.
-Og allocates 312 bytes for it and -O0 allocates 8280 bytes for it.

By the way, clang 13 has `-fstack-usage` option like gcc, but clang 12 don't 
have it.
Since Ubuntu 20.04 have only clang 12, I use `-fstack-size-segment` and 
https://github.com/mvanotti/stack-sizes to get stack size.

----------
nosy: +methane

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46600>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to