[PATCH] D55771: [AST] Store the callee and argument expressions of CallExpr in a trailing array.

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 17 08:25:00 PST 2018


riccibruno created this revision.
riccibruno added a reviewer: rjmccall.
riccibruno added a project: clang.
Herald added subscribers: cfe-commits, javed.absar.
Herald added a reviewer: shafik.

Since `CallExpr::setNumArgs` has been removed, it is now possible to store the callee expression and the argument expressions of `CallExpr` in a trailing array. This saves one pointer per `CallExpr`, `CXXOperatorCallExpr`,
`CXXMemberCallExpr`, `CUDAKernelCallExpr` and `UserDefinedLiteral`.

Since `CallExpr` is used as a base of the above classes we cannot use `llvm::TrailingObjects`. Instead we store
the offset in bytes from the `this` pointer to the start of the trailing objects and manually do the casts + arithmetic.

Some notes:

1. I did not try to fit the number of arguments in the bit-fields of `Stmt`. This leaves some space for future additions and avoid the discussion about whether x bits are sufficient to hold the number of arguments.
2. It would be perfectly possible to recompute the offset to the trailing objects before accessing the trailing objects. However the trailing objects are frequently accessed and benchmarks show that it is slightly faster to just load the offset from the bit-fields. Additionally, because of 1), we have plenty of space in the bit-fields of `Stmt`.


Repository:
  rC Clang

https://reviews.llvm.org/D55771

Files:
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/Analysis/BodyFarm.cpp
  lib/CodeGen/CGObjC.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55771.178458.patch
Type: text/x-patch
Size: 72214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181217/04b8fa90/attachment-0001.bin>


More information about the cfe-commits mailing list