[llvm-branch-commits] [clang] [clang][builtin] Implement __builtin_allow_runtime_check (PR #87568)
Aaron Ballman via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Apr 12 07:12:26 PDT 2024
================
@@ -3464,6 +3464,34 @@ Query for this feature with ``__has_builtin(__builtin_trap)``.
``__builtin_arm_trap`` is lowered to the ``llvm.aarch64.break`` builtin, and then to ``brk #payload``.
+``__builtin_allow_runtime_check``
----------------
AaronBallman wrote:
> It needs to be compiler time lowered, so I think it should literals.
In that case, I think we want *constant expression* not just literal, right? e.g.,
```
constexpr const char *name = "name of check";
if (__builtin_allow_runtime_check(name)) {
}
```
is still able to be lowered at compile time. The reason I ask is because I'm thinking about template metaprogramming cases where you might want to do something along the lines of:
```
template <typename Ty>
struct S {
void mem_fun() {
if (__builtin_allow_runtime_check(Ty::check_name) && stuff) {
}
}
};
```
but maybe this is not a compelling use case? I don't insist on constant expression support, more just trying to verify that we support the expected usage patterns.
https://github.com/llvm/llvm-project/pull/87568
More information about the llvm-branch-commits
mailing list