r188910 - Move the logic for selecting the last feature in the command line to the driver.
Rafael Espindola
rafael.espindola at gmail.com
Wed Aug 21 10:34:32 PDT 2013
Author: rafael
Date: Wed Aug 21 12:34:32 2013
New Revision: 188910
URL: http://llvm.org/viewvc/llvm-project?rev=188910&view=rev
Log:
Move the logic for selecting the last feature in the command line to the driver.
This is a partial revert of r188817 now that the driver handles -target-feature
in a single place.
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/x86_features.c
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=188910&r1=188909&r2=188910&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Aug 21 12:34:32 2013
@@ -5503,26 +5503,10 @@ TargetInfo *TargetInfo::CreateTargetInfo
llvm::StringMap<bool> Features;
Target->getDefaultFeatures(Features);
- // Fist the last of each option;
- llvm::StringMap<unsigned> LastOpt;
- for (unsigned I = 0, N = Opts->FeaturesAsWritten.size();
- I < N; ++I) {
- const char *Name = Opts->FeaturesAsWritten[I].c_str() + 1;
- LastOpt[Name] = I;
- }
-
// Apply the user specified deltas.
for (unsigned I = 0, N = Opts->FeaturesAsWritten.size();
I < N; ++I) {
const char *Name = Opts->FeaturesAsWritten[I].c_str();
-
- // If this option was overridden, ignore it.
- llvm::StringMap<unsigned>::iterator LastI = LastOpt.find(Name + 1);
- assert(LastI != LastOpt.end());
- unsigned Last = LastI->second;
- if (Last != I)
- continue;
-
// Apply the feature via the target.
bool Enabled = Name[0] == '+';
Target->setFeatureEnabled(Features, Name + 1, Enabled);
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=188910&r1=188909&r2=188910&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Aug 21 12:34:32 2013
@@ -1431,11 +1431,26 @@ static void getTargetFeatures(const Driv
getX86TargetFeatures(Args, Features);
break;
}
- for (std::vector<const char *>::iterator I = Features.begin(),
- E = Features.end();
- I != E; ++I) {
+
+ // Find the last of each feature.
+ llvm::StringMap<unsigned> LastOpt;
+ for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+ const char *Name = Features[I];
+ assert(Name[0] == '-' || Name[0] == '+');
+ LastOpt[Name + 1] = I;
+ }
+
+ for (unsigned I = 0, N = Features.size(); I < N; ++I) {
+ // If this feature was overridden, ignore it.
+ const char *Name = Features[I];
+ llvm::StringMap<unsigned>::iterator LastI = LastOpt.find(Name + 1);
+ assert(LastI != LastOpt.end());
+ unsigned Last = LastI->second;
+ if (Last != I)
+ continue;
+
CmdArgs.push_back("-target-feature");
- CmdArgs.push_back(*I);
+ CmdArgs.push_back(Name);
}
}
Modified: cfe/trunk/test/Driver/x86_features.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/x86_features.c?rev=188910&r1=188909&r2=188910&view=diff
==============================================================================
--- cfe/trunk/test/Driver/x86_features.c (original)
+++ cfe/trunk/test/Driver/x86_features.c Wed Aug 21 12:34:32 2013
@@ -1,2 +1,3 @@
// RUN: %clang -target i386-unknown-unknown -### -S %s -msse -msse4 -mno-sse -mno-mmx -msse 2>&1 | FileCheck %s
-// CHECK: "pentium4" "-target-feature" "+sse" "-target-feature" "+sse4" "-target-feature" "-sse" "-target-feature" "-mmx" "-target-feature" "+sse"
+// CHECK: "pentium4" "-target-feature" "+sse4" "-target-feature" "-mmx" "-target-feature" "+sse"
+// Note that we filter out all but the last -m(no)sse.
More information about the cfe-commits
mailing list