[PATCH] D76599: Represent FP options in AST by special Statement node

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 23 04:53:42 PDT 2020


sepavloff created this revision.
sepavloff added reviewers: rsmith, rjmccall, andrew.w.kaylor, efriedma, mibintc, kpn, sammccall, hokein.
Herald added subscribers: martong, arphaman.
Herald added a project: clang.

Now FPOption object is stored in the bits of Stmt class. The space
there is limited by 7 bits, which is by far not enough as FPOption
is supposed to grow incorporating other options related to floating
point operations. The problem was discussed in
http://lists.llvm.org/pipermail/cfe-dev/2020-March/064850.html. In
short, attempts to put FPOption as a field to relevant AST classes
result in substantial increase of AST size because such field would
consume memory even for nodes that do not deal with FP operations.

As a solution, a new statement node `FloatingPragmaStmt` has been
added. It represents a pragma that modifies floating point options.
This statement is placed at the beginning of corresponding
`CompoundStmt`. It provides persistency for the FP options and
allows to maintain actual FP state. Other nodes such as BinaryOperator
do not have to have a copy of FPOption, thus no unnecessary memory
consumption occurs.

If more than one pragma are specified in a compound statement, there
is a separate node for each. Each node keeps FP options accumulated
from all previous pragma nodes and from this one. Pragma specified
at file level results in pragma nodes implicitly inserted into every
function body affected by the pragma. In compilation option result
in non-default FP options, the synthesized pragma is inserted as well.

There are cases when an expression occurs outside compound statement.
These are global variable initializers, default arguments and some
other. This solution does not work for them, a special expression
node is required for them, it will be implemented later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76599

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/AST/ast-dump-pragma.cpp
  clang/test/CodeGen/fp-contract-pragma.cpp
  clang/test/Coverage/c-language-features.inc
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76599.251990.patch
Type: text/x-patch
Size: 31422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200323/b9c8cc54/attachment-0001.bin>


More information about the cfe-commits mailing list