[llvm] [TLI] Make VecDesc statically initializable (PR #211307)
Madhur Amilkanthwar via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 02:56:16 PDT 2026
================
@@ -48,23 +48,28 @@ class VecDesc {
ElementCount VectorizationFactor;
bool Masked;
StringRef VABIPrefix;
- std::optional<CallingConv::ID> CC;
+ CallingConv::ID CC;
public:
VecDesc() = delete;
- VecDesc(StringRef ScalarFnName, StringRef VectorFnName,
- ElementCount VectorizationFactor, bool Masked, StringRef VABIPrefix,
- std::optional<CallingConv::ID> Conv)
+ constexpr VecDesc(StringRef ScalarFnName, StringRef VectorFnName,
+ ElementCount VectorizationFactor, bool Masked,
+ StringRef VABIPrefix,
+ std::optional<CallingConv::ID> Conv = std::nullopt)
: ScalarFnName(ScalarFnName), VectorFnName(VectorFnName),
VectorizationFactor(VectorizationFactor), Masked(Masked),
- VABIPrefix(VABIPrefix), CC(Conv) {}
+ VABIPrefix(VABIPrefix), CC(Conv.value_or(CallingConv::C)) {}
----------------
madhur13490 wrote:
The above rewrite should also drop `optional::value_or` from the constexpr constructor. `value_or` isn’t constexpr until C++20, and LLVM still builds as C++17 by default, so a ternary like `Conv.has_value() ? *Conv + 1 : 0` is safer for actual constant initialization.
https://github.com/llvm/llvm-project/pull/211307
More information about the llvm-commits
mailing list