[llvm] [TLI] Make VecDesc statically initializable (PR #211307)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 08:10:04 PDT 2026
huntergr-arm wrote:
> > While I don't like it, the change does make sense until we're allowed to use more recent versions of C++. Perhaps add a comment to change back to std::optional once we can?
>
> `std::optional<CallingConv::ID>` is the main reason that the large static const VecDesc[] tables require dynamic static initialization at DLL load time. At some cases during MSVC Debug build CRT init run on threads with limited stack, causing stack overflow and load failure. In other words the removal of std::optional is a crucial fix. At the same time for C++ 20 and higher we can use `CallingConv::ID` type and `optional::value_or()` function so the 0 / CC+1 encoding can be roll back since newer default C++ version. I can add the comment about it to the code
>
> cc @huntergr-arm
Yes, that's what I meant -- this code is needed for now to address the stack size bug, but can be changed back once we're allowed to use C++20 or higher for LLVM itself because we'll have constexpr std::optional then.
https://github.com/llvm/llvm-project/pull/211307
More information about the llvm-commits
mailing list