[clang] da3ea31 - [clang][bytecode] Avoid copying function call arguments (#218399)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 24 07:48:36 PDT 2026
Author: Timm Baeder
Date: 2026-08-24T16:48:31+02:00
New Revision: da3ea310333e17d1882efb633439602dea7c4460
URL: https://github.com/llvm/llvm-project/commit/da3ea310333e17d1882efb633439602dea7c4460
DIFF: https://github.com/llvm/llvm-project/commit/da3ea310333e17d1882efb633439602dea7c4460.diff
LOG: [clang][bytecode] Avoid copying function call arguments (#218399)
In most cases, we dony' need the SmallVector (we only use it to reverse
the arguments in the assignment operator case).
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index a6378cdf63243..3f641911895d2 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -6206,7 +6206,8 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
}
}
- SmallVector<const Expr *, 8> Args(ArrayRef(E->getArgs(), E->getNumArgs()));
+ ArrayRef<const Expr *> Args(E->getArgs(), E->getNumArgs());
+ const Expr *ReversedArgs[2];
bool IsAssignmentOperatorCall = false;
bool ActivateLHS = false;
@@ -6219,7 +6220,9 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
const CXXRecordDecl *LHSRecord = Args[0]->getType()->getAsCXXRecordDecl();
ActivateLHS = LHSRecord && LHSRecord->hasTrivialDefaultConstructor();
IsAssignmentOperatorCall = true;
- std::reverse(Args.begin(), Args.end());
+ ReversedArgs[0] = Args[1];
+ ReversedArgs[1] = Args[0];
+ Args = ReversedArgs;
}
// Calling a static operator will still
// pass the instance, but we don't need it.
@@ -6230,7 +6233,7 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
if (!this->discard(E->getArg(0)))
return false;
// Drop first arg.
- Args.erase(Args.begin());
+ Args = Args.drop_front();
}
}
More information about the cfe-commits
mailing list