[PATCH] D46030: [TargetInfo] Sort target features before passing them to the backend
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 24 15:24:34 PDT 2018
efriedma created this revision.
efriedma added reviewers: fhahn, SjoerdMeijer.
Herald added a reviewer: javed.absar.
Herald added a subscriber: kristof.beyls.
Passing the features in random order will lead to unpredictable results when some of the features are related (like the architecture-version feature 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.
Repository:
rC Clang
https://reviews.llvm.org/D46030
Files:
lib/Basic/Targets.cpp
test/CodeGen/arm-build-attributes.c
Index: test/CodeGen/arm-build-attributes.c
===================================================================
--- /dev/null
+++ test/CodeGen/arm-build-attributes.c
@@ -0,0 +1,3 @@
+// RUN: %clang --target=arm-none-eabi -x c - -o - -S < %s -mcpu=cortex-a5 -mfpu=vfpv4-d16 | FileCheck %s
+// CHECK: .fpu vfpv4-d16
+void foo() {}
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -638,6 +638,7 @@
Opts->Features.clear();
for (const auto &F : Features)
Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str());
+ llvm::sort(Opts->Features.begin(), Opts->Features.end());
if (!Target->handleTargetFeatures(Opts->Features, Diags))
return nullptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46030.143820.patch
Type: text/x-patch
Size: 781 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180424/1e292322/attachment.bin>
More information about the cfe-commits
mailing list