[all-commits] [llvm/llvm-project] f7819c: [FPEnv] Allow CompoundStmt to keep FP options
Serge Pavlov via All-commits
all-commits at lists.llvm.org
Sun Jul 3 03:07:22 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f7819ce166bcc472108cf7c05f86edcf4ee9e6cf
https://github.com/llvm/llvm-project/commit/f7819ce166bcc472108cf7c05f86edcf4ee9e6cf
Author: Serge Pavlov <sepavloff at gmail.com>
Date: 2022-07-03 (Sun, 03 Jul 2022)
Changed paths:
M clang/include/clang/AST/JSONNodeDumper.h
M clang/include/clang/AST/Stmt.h
M clang/include/clang/AST/TextNodeDumper.h
M clang/include/clang/Basic/LangOptions.h
M clang/include/clang/Sema/ScopeInfo.h
M clang/lib/AST/ASTImporter.cpp
M clang/lib/AST/JSONNodeDumper.cpp
M clang/lib/AST/Stmt.cpp
M clang/lib/AST/StmtPrinter.cpp
M clang/lib/AST/TextNodeDumper.cpp
M clang/lib/Analysis/BodyFarm.cpp
M clang/lib/Basic/LangOptions.cpp
M clang/lib/CodeGen/CGCoroutine.cpp
M clang/lib/Sema/Sema.cpp
M clang/lib/Sema/SemaDeclCXX.cpp
M clang/lib/Sema/SemaExprCXX.cpp
M clang/lib/Sema/SemaOpenMP.cpp
M clang/lib/Sema/SemaStmt.cpp
M clang/lib/Serialization/ASTReaderStmt.cpp
M clang/lib/Serialization/ASTWriterStmt.cpp
M clang/test/AST/ast-dump-fpfeatures.cpp
A clang/test/AST/ast-dump-pragma-json.c
A clang/test/AST/ast-print-fp-pragmas.c
Log Message:
-----------
[FPEnv] Allow CompoundStmt to keep FP options
This is a recommit of b822efc7404bf09ccfdc1ab7657475026966c3b2,
reverted in dc34d8df4c48b3a8f474360970cae8a58e6c84f0. The commit caused
fails because the test ast-print-fp-pragmas.c did not specify particular
target, and it failed on targets which do not support constrained
intrinsics. The original commit message is below.
AST does not have special nodes for pragmas. Instead a pragma modifies
some state variables of Sema, which in turn results in modified
attributes of AST nodes. This technique applies to floating point
operations as well. Every AST node that can depend on FP options keeps
current set of them.
This technique works well for options like exception behavior or fast
math options. They represent instructions to the compiler how to modify
code generation for the affected nodes. However treatment of FP control
modes has problems with this technique. Modifying FP control mode
(like rounding direction) usually requires operations on hardware, like
writing to control registers. It must be done prior to the first
operation that depends on the control mode. In particular, such
operations are required for implementation of `pragma STDC FENV_ROUND`,
compiler should set up necessary rounding direction at the beginning of
compound statement where the pragma occurs. As there is no representation
for pragmas in AST, the code generation becomes a complicated task in
this case.
To solve this issue FP options are kept inside CompoundStmt. Unlike to FP
options in expressions, these does not affect any operation on FP values,
but only inform the codegen about the FP options that act in the body of
the statement. As all pragmas that modify FP environment may occurs only
at the start of compound statement or at global level, such solution
works for all relevant pragmas. The options are kept as a difference
from the options in the enclosing compound statement or default options,
it helps codegen to set only changed control modes.
Differential Revision: https://reviews.llvm.org/D123952
More information about the All-commits
mailing list