This is an archive of the discontinued LLVM Phabricator instance.

Represent FP options in AST by special Statement node
AbandonedPublic

Authored by sepavloff on Mar 23 2020, 4:45 AM.

Details

Summary

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.

Diff Detail