[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress

Melanie Blower via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 11 10:09:52 PDT 2020


mibintc created this revision.
mibintc added reviewers: sepavloff, rjmccall.
Herald added a project: clang.
mibintc requested review of this revision.

I rebased https://reviews.llvm.org/D69272 to work on the blocking comment from @rsmith 
@sepavloff Is it OK if I continue work on this item?  Not sure about the protocol when continuing someone else's patch.

@rsmith asked "I don't see changes to the constant evaluator".  The semantic rules for enabling this pragma require that strict or precise semantics be in effect., see SemaAttr.cpp  And the floating point constant evaluation doesn't occur when strict or precise

One of the test cases in this patch shows 1+2 isn't folded in strict mode.

However, I don't see where is the decision about floating point constant folding, can someone tell me where that occurs? . I thought the constant folding was in AST/ExprConstant.cpp and indeed constant folding does occur there. But sometimes, if the floating point semantics are set to 'strict', even tho' folding has occurred successfully in ExprConstant.cpp, when i look at emit-llvm, there is arithmetic emitted for the floating point expression;  For example if you use the command line option -ffp-exception-behavior=strict and you compile this function, it will emit the add instruction; but without the option you will see the folded expression 3.0.  Either way (i.e. regardless of option) if you put a breakpoint inside ExprConstant.cpp the calculation of the floating sum does occur.  The function is float myAdd(void) { return 1.0 + 2.0; }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87528

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/CodeGen/pragma-fenv_access.c
  clang/test/Parser/fp-floatcontrol-syntax.cpp
  clang/test/Parser/pragma-fenv_access.c
  clang/test/Preprocessor/pragma_unknown.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87528.291258.patch
Type: text/x-patch
Size: 12243 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200911/bc3fa881/attachment-0001.bin>


More information about the cfe-commits mailing list