[clang] [clang][bytecode][NFC] Remove reflection indirection in builtins (PR #237106)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 29 22:51:30 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
The additional indirection through InterpretReflectionBuiltin adds nothing other than more complexity and a function call that returns `false` for basically ALL cases.
Remove the call to InterpretReflectionBuiltin and just add the reflection builtin to the existing switch. If this file gets to big, we can still move the individual reflection functions in a different file.
---
Full diff: https://github.com/llvm/llvm-project/pull/237106.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+4-14)
``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 8fefaa97c9f63..51ea5469f2af6 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -4780,22 +4780,8 @@ static bool interp__builtin_meta_is_type(InterpState &S, CodePtr OpPC,
return true;
}
-static bool InterpretReflectionBuiltin(InterpState &S, CodePtr OpPC,
- const CallExpr *Call,
- uint32_t BuiltinID) {
- switch (BuiltinID) {
- case Builtin::BI__builtin_meta_is_type:
- return interp__builtin_meta_is_type(S, OpPC, Call);
- default:
- llvm_unreachable("unknown metafunction builtin");
- }
-}
-
bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
uint32_t BuiltinID) {
- if (S.getASTContext().BuiltinInfo.isReflectionMetafunctionBuiltin(BuiltinID))
- return InterpretReflectionBuiltin(S, OpPC, Call, BuiltinID);
-
const InterpFrame *Frame = S.Current;
switch (BuiltinID) {
case Builtin::BI__builtin_is_constant_evaluated:
@@ -6951,6 +6937,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
case X86::BI__builtin_ia32_cvttpd2dq256:
case X86::BI__builtin_ia32_cvttps2dq256:
return interp_builtin_ia32_cvt_vector_to_int(S, OpPC, Call);
+
+ case Builtin::BI__builtin_meta_is_type:
+ return interp__builtin_meta_is_type(S, OpPC, Call);
+
default:
return Invalid(S, OpPC);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/237106
More information about the cfe-commits
mailing list