[clang] [clang][bytecode] Short-circuit inelegible functions when compiling (PR #225618)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 00:26:25 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
Don't bother setting up parameter maps for functions we know we won't compile.
---
Full diff: https://github.com/llvm/llvm-project/pull/225618.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/ByteCodeEmitter.cpp (+12-8)
``````````diff
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;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/225618
More information about the cfe-commits
mailing list