clang emits useless guard variable for static const value
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Please see https://godbolt.org/z/K6bM5qfx3 and compare the gcc and clang output
The compiler is able to calculate the `pow` results at compile time, however it still issues a __cxa_guard_acquire/__cxa_guard_release pair just to move those values around in memory. Meanwhile, gcc is able to use the .rodata section directly.
Contributor guide
Research direction
Start with the Godbolt reproducer at https://godbolt.org/z/K6bM5qfx3 and compare the Clang and GCC assembly output. Trace how Clang handles compile-time pow evaluation for the static const value and emits __cxa_guard_acquire/__cxa_guard_release. Done means the unnecessary guard pair is no longer emitted when the values can be placed directly in .rodata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100