llvm-project/clang/lib
Simon Tatham 5d66f2b0af [ARM] Fix bugs introduced by the fp64/d32 rework.
Change D60691 caused some knock-on failures that weren't caught by the
existing tests. Firstly, selecting a CPU that should have had a
restricted FPU (e.g. `-mcpu=cortex-m4`, which should have 16 d-regs
and no double precision) could give the unrestricted version, because
`ARM::getFPUFeatures` returned a list of features including subtracted
ones (here `-fp64`,`-d32`), but `ARMTargetInfo::initFeatureMap` threw
away all the ones that didn't start with `+`. Secondly, the
preprocessor macros didn't reliably match the actual compilation
settings: for example, `-mfpu=softvfp` could still set `__ARM_FP` as
if hardware FP was available, because the list of features on the cc1
command line would include things like `+vfp4`,`-vfp4d16` and clang
didn't realise that one of those cancelled out the other.

I've fixed both of these issues by rewriting `ARM::getFPUFeatures` so
that it returns a list that enables every FP-related feature
compatible with the selected FPU and disables every feature not
compatible, which is more verbose but means clang doesn't have to
understand the dependency relationships between the backend features.
Meanwhile, `ARMTargetInfo::handleTargetFeatures` is testing for all
the various forms of the FP feature names, so that it won't miss cases
where it should have set `HW_FP` to feed into feature test macros.

That in turn caused an ordering problem when handling `-mcpu=foo+bar`
together with `-mfpu=something_that_turns_off_bar`. To fix that, I've
arranged that the `+bar` suffixes on the end of `-mcpu` and `-march`
cause feature names to be put into a separate vector which is
concatenated after the output of `getFPUFeatures`.

Another side effect of all this is to fix a bug where `clang -target
armv8-eabi` by itself would fail to set `__ARM_FEATURE_FMA`, even
though `armv8` (aka Arm v8-A) implies FP-Armv8 which has FMA. That was
because `HW_FP` was being set to a value including only the `FPARMV8`
bit, but that feature test macro was testing only the `VFP4FPU` bit.
Now `HW_FP` ends up with all the bits set, so it gives the right
answer.

Changes to tests included in this patch:

* `arm-target-features.c`: I had to change basically all the expected
  results. (The Cortex-M4 test in there should function as a
  regression test for the accidental double-precision bug.)
* `arm-mfpu.c`, `armv8.1m.main.c`: switched to using `CHECK-DAG`
  everywhere so that those tests are no longer sensitive to the order
  of cc1 feature options on the command line.
* `arm-acle-6.5.c`: been updated to expect the right answer to that
  FMA test.
* `Preprocessor/arm-target-features.c`: added a regression test for
  the `mfpu=softvfp` issue.

Reviewers: SjoerdMeijer, dmgreen, ostannard, samparker, JamesNagurne

Reviewed By: ostannard

Subscribers: srhines, javed.absar, kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 362791
2019-06-07 12:42:54 +00:00
..
ARCMigrate Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an attribute declaration" 2019-05-07 03:20:17 +00:00
AST Convert MemberExpr creation and serialization to work the same way as 2019-06-06 23:24:15 +00:00
ASTMatchers Move TraversalKind enum to ast_type_traits 2019-05-16 17:57:38 +00:00
Analysis [Analysis] Only build Analysis plugins when CLANG_ENABLE_STATIC_ANALYZER is enabled. 2019-06-04 22:07:40 +00:00
Basic [ARM] Fix bugs introduced by the fp64/d32 rework. 2019-06-07 12:42:54 +00:00
CodeGen LLVM IR: Generate new-style byval-with-Type from Clang 2019-06-05 21:12:14 +00:00
CrossTU [ASTImporter] Use llvm::Expected and Error in the importer API 2019-05-15 10:29:48 +00:00
Driver [ARM] Fix bugs introduced by the fp64/d32 rework. 2019-06-07 12:42:54 +00:00
Edit Range-style std::find{,_if} -> llvm::find{,_if}. NFC 2019-03-31 08:48:19 +00:00
Format clang-format: better handle namespace macros 2019-06-06 20:06:23 +00:00
Frontend Convert MemberExpr creation and serialization to work the same way as 2019-06-06 23:24:15 +00:00
FrontendTool Add clang source minimizer that reduces source to directives 2019-06-03 22:59:17 +00:00
Headers [X86] Add ENQCMD instructions 2019-06-06 08:28:42 +00:00
Index [Index] Compute correct symbol kind for variable templates 2019-05-29 17:49:30 +00:00
Lex [clang][HeaderSearch] Consider all path separators equal 2019-06-06 18:49:16 +00:00
Parse Re-check in clang support gun asm goto after fixing tests. 2019-06-03 15:57:25 +00:00
Rewrite [analyzer] [NFC] PathDiagnostic: Create PathDiagnosticPopUpPiece 2019-05-29 19:21:59 +00:00
Sema [CodeComplete] Improve overload handling for C++ qualified and ref-qualified methods. 2019-06-07 09:45:17 +00:00
Serialization Convert MemberExpr creation and serialization to work the same way as 2019-06-06 23:24:15 +00:00
StaticAnalyzer [analyzer] PathDiagnosticPopUpPiece: working with CharSourceRange 2019-06-05 18:55:39 +00:00
Tooling [LibTooling] Add `before` and `after` selectors for selecting point-ranges relative to nodes. 2019-05-29 12:40:36 +00:00
CMakeLists.txt Add Cross Translation Unit support library 2017-09-22 11:11:01 +00:00