diff options
author | Eli Friedman <efriedma@codeaurora.org> | 2018-04-25 19:14:05 +0000 |
---|---|---|
committer | Eli Friedman <efriedma@codeaurora.org> | 2018-04-25 19:14:05 +0000 |
commit | e54d0ff400c9c6848a1d6f0a16c42eb2670d69c7 (patch) | |
tree | f213b1f62540de1ffb4f8446c6fd6ac8d064b1a5 /clang/lib/Basic/Targets.cpp | |
parent | cb8ca5f37c29bef9b5b1f119d7ab10ae288956c9 (diff) | |
download | bcm5719-llvm-e54d0ff400c9c6848a1d6f0a16c42eb2670d69c7.tar.gz bcm5719-llvm-e54d0ff400c9c6848a1d6f0a16c42eb2670d69c7.zip |
[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
llvm-svn: 330861
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index e325403a1fa..2e4b722b852 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -638,6 +638,9 @@ TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, 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; |