src: Allow clang-style +/- for target features

This largely works as expected, except that as far as I can tell,
without explicit annotations added to the caller, (or a
`#force_inline`), the LLVM `target-features` function attribute
gets ignored by the inliner under the rationale of `-sse,-avx,-avx2`
is a subset of `+sse,+avx,+avx2`.

With `#force_no_inline` the correct code does get generated, but in
the regression I am trying to fix, the caller gratuitously also uses
SIMD, leading to horrific performance.
This commit is contained in:
Yawning Angel
2026-03-18 05:13:44 +09:00
parent fdbbcc509c
commit 62d78d61fa
2 changed files with 24 additions and 8 deletions

View File

@@ -201,12 +201,15 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
for (;;) {
String str = string_split_iterator(&it, ',');
if (str == "") break;
bool add_prefix = !(string_starts_with(str, '+') || string_starts_with(str, '-'));
if (!first) {
feature_str = gb_string_appendc(feature_str, ",");
}
first = false;
feature_str = gb_string_appendc(feature_str, "+");
if (add_prefix) {
feature_str = gb_string_appendc(feature_str, "+");
}
feature_str = gb_string_append_length(feature_str, str.text, str.len);
}