[PATCH] D53607: [AST] Only store the needed data in IfStmt.

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 23 13:28:36 PDT 2018


riccibruno created this revision.
riccibruno added a reviewer: rjmccall.
riccibruno added a project: clang.
Herald added subscribers: cfe-commits, javed.absar.
riccibruno added a dependency: D53605: [AST] Pack PredefinedExpr.

Only store the needed data in `IfStmt`. The various `Stmt *` are put in
a trailing array with the commonly used `Stmt *` first (like the condition
and the then statement) and the less commonly used `Stmt *` last.
This cuts the size of `IfStmt` by up to 3 pointers + 1 `SourceLocation`.

One point which must be discussed is that this changes the order of the
children. This is strictly speaking not needed (we could just compute the
appropriate index into the trailing array) but this allows the common data
to be at a constant offset into the trailing array. This saves us from doing
bit manipulations and arithmetic each time the commonly used data is accessed.

I believe the C API is unaffected since it do not rely on calling `children` on `IfStmt`.
This also makes modifying an `IfStmt` after creation harder since the necessary
storage might not exist.


Repository:
  rC Clang

https://reviews.llvm.org/D53607

Files:
  include/clang/AST/Stmt.h
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/Analysis/BodyFarm.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Import/if-stmt/test.cpp
  test/Misc/ast-dump-invalid.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53607.170736.patch
Type: text/x-patch
Size: 21979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181023/af7862af/attachment-0001.bin>


More information about the cfe-commits mailing list