Author: efriedma Date: Wed Apr 25 12:14:05 2018 New Revision: 330861 URL: http://llvm.org/viewvc/llvm-project?rev=330861&view=rev Log: [TargetInfo] Sort target features before passing them to the backend
Passing the features in random order will lead to unpredictable results when some of the features are related (like the architecture-version features on ARM). It might be possible to fix this particular case in the ARM target code, to avoid adding overlapping target features. But we should probably be sorting in any case: the behavior shouldn't depend on StringMap's hashing algorithm. Differential Revision: https://reviews.llvm.org/D46030 Added: cfe/trunk/test/CodeGen/arm-build-attributes.c Modified: cfe/trunk/lib/Basic/Targets.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=330861&r1=330860&r2=330861&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Wed Apr 25 12:14:05 2018 @@ -638,6 +638,9 @@ TargetInfo::CreateTargetInfo(Diagnostics Opts->Features.clear(); for (const auto &F : Features) Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str()); + // Sort here, so we handle the features in a predictable order. (This matters + // when we're dealing with features that overlap.) + llvm::sort(Opts->Features.begin(), Opts->Features.end()); if (!Target->handleTargetFeatures(Opts->Features, Diags)) return nullptr; Added: cfe/trunk/test/CodeGen/arm-build-attributes.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-build-attributes.c?rev=330861&view=auto ============================================================================== --- cfe/trunk/test/CodeGen/arm-build-attributes.c (added) +++ cfe/trunk/test/CodeGen/arm-build-attributes.c Wed Apr 25 12:14:05 2018 @@ -0,0 +1,4 @@ +// RUN: %clang --target=arm-none-eabi -x c - -o - -S < %s -mcpu=cortex-a5 -mfpu=vfpv4-d16 | FileCheck %s +// REQUIRES: arm-registered-target +// CHECK: .fpu vfpv4-d16 +void foo() {} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits