[clang] 0601a12 - [clang][bytecode] Short-circuit inelegible functions when compiling (#225618)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 07:48:02 PDT 2026
Author: Timm Baeder
Date: 2026-09-23T16:47:54+02:00
New Revision: 0601a126c256e09faea980045ac0b787b49dfe39
URL: https://github.com/llvm/llvm-project/commit/0601a126c256e09faea980045ac0b787b49dfe39
DIFF: https://github.com/llvm/llvm-project/commit/0601a126c256e09faea980045ac0b787b49dfe39.diff
LOG: [clang][bytecode] Short-circuit inelegible functions when compiling (#225618)
Don't bother setting up parameter maps for functions we know we won't
compile.
Added:
Modified:
clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp b/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
index bc1ef1bb6e7b2..2b2e6be3bdce2 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