[clang] [clang][bytecode] Short-circuit inelegible functions when compiling (PR #225618)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 04:53:11 PDT 2026
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/225618
>From 3e0d63dc444454c8b13b431637f97ad89b9d0445 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sun, 20 Sep 2026 11:36:59 +0200
Subject: [PATCH] func compile switch
---
clang/lib/AST/ByteCode/ByteCodeEmitter.cpp | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp b/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
index bc1ef1bb6e7b22..2b2e6be3bdce25 100644
--- a/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
@@ -26,6 +26,17 @@ void ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl,
assert(Func);
assert(FuncDecl->isThisDeclarationADefinition());
+ Func->setDefined(true);
+ // Lambda static invokers are a special case that we emit custom code for.
+ bool IsEligibleForCompilation = Func->isLambdaStaticInvoker() ||
+ FuncDecl->isConstexpr() ||
+ FuncDecl->hasAttr<MSConstexprAttr>();
+
+ if (!IsEligibleForCompilation) {
+ Func->setIsFullyCompiled(true);
+ return;
+ }
+
// Set up lambda captures.
if (Func->isLambdaCallOperator()) {
// Set up lambda capture to closure record field mapping.
@@ -59,15 +70,8 @@ void ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl,
this->Params.insert({PD, {ParamIndex, Ctx.canClassify(PD->getType())}});
}
- Func->setDefined(true);
-
- // Lambda static invokers are a special case that we emit custom code for.
- bool IsEligibleForCompilation = Func->isLambdaStaticInvoker() ||
- FuncDecl->isConstexpr() ||
- FuncDecl->hasAttr<MSConstexprAttr>();
-
// Compile the function body.
- if (!IsEligibleForCompilation || !visitFunc(FuncDecl)) {
+ if (!visitFunc(FuncDecl)) {
Func->setIsFullyCompiled(true);
return;
}
More information about the cfe-commits
mailing list