-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] Mark __builtin_convertvector
and __builtin_shufflevector
as constexpr
.
#112129
Conversation
@llvm/pr-subscribers-clang Author: None (c8ef) ChangesCloses #107985. Full diff: https://github.com/llvm/llvm-project/pull/112129.diff 1 Files Affected:
diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td
index 7068473a0e12ac..362de6cfa9d0e1 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -1186,13 +1186,13 @@ def AllowRuntimeCheck : Builtin {
def ShuffleVector : Builtin {
let Spellings = ["__builtin_shufflevector"];
- let Attributes = [NoThrow, Const, CustomTypeChecking];
+ let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
let Prototype = "void(...)";
}
def ConvertVector : Builtin {
let Spellings = ["__builtin_convertvector"];
- let Attributes = [NoThrow, Const, CustomTypeChecking];
+ let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
let Prototype = "void(...)";
}
|
How are we already able to use these in constexpr if they are missing the attribute? |
I believe the difference lies in the AST construction. Most built-in functions generate a |
And I think we need to align these two to make the feature test macro work. |
Anyway you can test that? |
You can directly view it from the Clang AST on Godbolt. For this patch, I don't believe additional tests are necessary. |
Any bugfix should contain a regression test. Here you could simply check that |
…as `constexpr`. (llvm#112129) Closes llvm#107985. LanguageExtensions.rst states that `__builtin_shufflevector` and `__builtin_convertvector` can be evaluated as constants, but this is not reflected in Butiltins.td. This patch aligns these two.
…as `constexpr`. (llvm#112129) Closes llvm#107985. LanguageExtensions.rst states that `__builtin_shufflevector` and `__builtin_convertvector` can be evaluated as constants, but this is not reflected in Butiltins.td. This patch aligns these two.
…as `constexpr`. (llvm#112129) Closes llvm#107985. LanguageExtensions.rst states that `__builtin_shufflevector` and `__builtin_convertvector` can be evaluated as constants, but this is not reflected in Butiltins.td. This patch aligns these two.
Closes #107985.
LanguageExtensions.rst states that
__builtin_shufflevector
and__builtin_convertvector
can be evaluated as constants, but this is not reflected in Butiltins.td. This patch aligns these two.