llvm-project/clang/test
Sanjay Patel cb8c009801 [Driver, CodeGen] pass through and apply -fassociative-math
There are 2 parts to getting the -fassociative-math command-line flag translated to LLVM FMF:

1. In the driver/frontend, we accept the flag and its 'no' inverse and deal with the 
   interactions with other flags like -ffast-math -fno-signed-zeros -fno-trapping-math. 
   This was mostly already done - we just need to translate the flag as a codegen option. 
   The test file is complicated because there are many potential combinations of flags here.
   Note that we are matching gcc's behavior that requires 'nsz' and no-trapping-math.

2. In codegen, we map the codegen option to FMF in the IR builder. This is simple code and 
   corresponding test.

For the motivating example from PR27372:

float foo(float a, float x) { return ((a + x) - x); }

$ ./clang -O2 27372.c -S -o - -ffast-math  -fno-associative-math -emit-llvm  | egrep 'fadd|fsub'
  %add = fadd nnan ninf nsz arcp contract float %0, %1
  %sub = fsub nnan ninf nsz arcp contract float %add, %2

So 'reassoc' is off as expected (and so is the new 'afn' but that's a different patch). 
This case now works as expected end-to-end although the underlying logic is still wrong:

$ ./clang  -O2 27372.c -S -o - -ffast-math  -fno-associative-math | grep xmm
	addss	%xmm1, %xmm0
	subss	%xmm1, %xmm0

We're not done because the case where 'reassoc' is set is ignored by optimizer passes. Example:

$ ./clang  -O2 27372.c -S -o - -fassociative-math -fno-signed-zeros -fno-trapping-math -emit-llvm  | grep fadd
  %add = fadd reassoc float %0, %1

$ ./clang -O2  27372.c -S -o - -fassociative-math -fno-signed-zeros -fno-trapping-math | grep xmm
	addss	%xmm1, %xmm0
	subss	%xmm1, %xmm0

Differential Revision: https://reviews.llvm.org/D39812

llvm-svn: 320920
2017-12-16 16:11:17 +00:00
..
ARCMT
ASTMerge [ASTImporter] Support new AST nodes: 2017-11-21 16:08:41 +00:00
Analysis [analyzer] StackAddrEscape: For now, disable the new async escape checks. 2017-12-12 02:59:09 +00:00
CXX P0620 follow-up: deducing `auto` from braced-init-list in new expr 2017-12-11 18:29:54 +00:00
CodeCompletion [Sema] Ignore decls in namespaces when global decls are not wanted. 2017-12-13 10:26:49 +00:00
CodeGen [Driver, CodeGen] pass through and apply -fassociative-math 2017-12-16 16:11:17 +00:00
CodeGenCUDA
CodeGenCXX [c++20] P0515R3: Parsing support and basic AST construction for operator <=>. 2017-12-14 15:16:18 +00:00
CodeGenCoroutines [coroutines] Promote cleanup.dest.slot allocas to registers to avoid storing it in the coroutine frame 2017-11-11 17:00:43 +00:00
CodeGenObjC [Blocks] Inherit sanitizer options from parent decl 2017-12-08 02:47:58 +00:00
CodeGenObjCXX In an ARC lambda-to-block conversion thunk, reclaim the return value of 2017-12-14 18:21:14 +00:00
CodeGenOpenCL CodeGen: Fix invalid bitcasts for memcpy 2017-12-07 01:39:52 +00:00
Coverage [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output 2017-08-03 18:12:22 +00:00
CoverageMapping [Coverage] Emit gap areas in braces-optional statements (PR35387) 2017-11-29 22:25:14 +00:00
Driver [Driver, CodeGen] pass through and apply -fassociative-math 2017-12-16 16:11:17 +00:00
FixIt Add a "vexing parse" warning for ambiguity between a variable declaration and a 2017-09-29 23:57:25 +00:00
Format [clang] Get rid of "%T" expansions 2017-08-15 19:47:06 +00:00
Frontend [VerifyDiagnosticConsumer] support -verify=<prefixes> 2017-12-16 02:23:22 +00:00
Headers In stdbool.h, define bool, false, true only in gnu++98 2017-12-08 08:28:08 +00:00
Import Add support for remembering origins to ExternalASTMerger 2017-09-27 19:57:58 +00:00
Index [libclang] Add support for checking abstractness of records 2017-12-14 22:01:50 +00:00
Integration Fix the test fix from r312181 2017-08-30 23:26:38 +00:00
Layout
Lexer Warn if we find a Unicode homoglyph for a symbol in an identifier. 2017-12-14 13:15:08 +00:00
Misc Determine the attribute subject for diagnostics based on declarative information in DeclNodes.td. This greatly reduces the number of enumerated values used for more complex diagnostics; these are now only required when the "attribute only applies to" diagnostic needs to be generated manually as part of semantic processing. 2017-11-26 20:01:12 +00:00
Modules Revert r320230 to fix buildbots. 2017-12-09 03:02:21 +00:00
OpenMP [OPENMP] Codegen `declare simd` for function declarations. 2017-12-15 16:28:31 +00:00
PCH Correctly handle line table entries without filenames during AST serialization 2017-12-04 22:28:45 +00:00
Parser [c++20] P0515R3: Parsing support and basic AST construction for operator <=>. 2017-12-14 15:16:18 +00:00
Preprocessor __is_target_environment: Check the environment after parsing it 2017-12-15 20:07:53 +00:00
Profile [PGO] Detect more structural changes with the stable hash 2017-11-14 23:56:53 +00:00
Refactor [refactor][extract] avoid extracting expressions from types in functions 2017-11-14 18:59:01 +00:00
Rewriter [clang] Remove unit test which uses reverse-iterate flag 2017-08-24 22:40:32 +00:00
Sema [VerifyDiagnosticConsumer] support -verify=<prefixes> 2017-12-16 02:23:22 +00:00
SemaCUDA [CUDA] Report "unsupported VLA" errors only on device side. 2017-11-28 18:51:42 +00:00
SemaCXX Correct UnaryTransformTypeLoc to properly initialize. 2017-12-14 23:37:08 +00:00
SemaObjC Determine the attribute subject for diagnostics based on declarative information in DeclNodes.td. This greatly reduces the number of enumerated values used for more complex diagnostics; these are now only required when the "attribute only applies to" diagnostic needs to be generated manually as part of semantic processing. 2017-11-26 20:01:12 +00:00
SemaObjCXX [ObjC++] Don't warn about pessimizing move for __block variables 2017-11-07 21:40:11 +00:00
SemaOpenCL [OpenCL] Add extensions cl_intel_subgroups and cl_intel_subgroups_short 2017-11-27 09:14:17 +00:00
SemaTemplate When attempting to complete an incomplete array bound type in an expression, 2017-12-14 15:40:16 +00:00
TableGen
Tooling [tooling] Make compile_flags.txt negative test more hermetic 2017-11-14 15:22:34 +00:00
Unit [lit] Set shlibpath_var on Solaris 2017-11-27 13:33:19 +00:00
VFS
clang-rename [clang-rename] Fix and enable the failing TemplatedClassFunction test. 2017-10-25 08:25:25 +00:00
.clang-format
CMakeLists.txt [cmake] Follow-up to rL320494. 2017-12-12 19:47:40 +00:00
TestRunner.sh
cxx-sections.data
lit.cfg.py [debuginfo] Remove temporary FIXME. 2017-12-14 22:12:46 +00:00
lit.site.cfg.py.in [lit] Add host_cxx to lit config 2017-10-10 17:53:45 +00:00
make_test_dirs.pl