CmdArgs.push_back(CPUName);
}
+ // The required algorithm here is slightly strange: the options are applied
+ // in order (so -mno-sse -msse2 disables SSE3), but any option that gets
+ // directly overridden later is ignored (so "-mno-sse -msse2 -mno-sse2 -msse"
+ // is equivalent to "-mno-sse2 -msse"). The -cc1 handling deals with the
+ // former correctly, but not the latter; handle directly-overridden
+ // attributes here.
+ llvm::StringMap<unsigned> PrevFeature;
+ std::vector<const char*> Features;
for (arg_iterator it = Args.filtered_begin(options::OPT_m_x86_Features_Group),
ie = Args.filtered_end(); it != ie; ++it) {
llvm::StringRef Name = (*it)->getOption().getName();
if (IsNegative)
Name = Name.substr(3);
- CmdArgs.push_back("-target-feature");
- CmdArgs.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
+ unsigned& Prev = PrevFeature[Name];
+ if (Prev)
+ Features[Prev - 1] = 0;
+ Prev = Features.size() + 1;
+ Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
+ }
+ for (unsigned i = 0; i < Features.size(); i++) {
+ if (Features[i]) {
+ CmdArgs.push_back("-target-feature");
+ CmdArgs.push_back(Features[i]);
+ }
}
}
// RUN: %clang -ccc-host-triple i386-unknown-unknown -### -S %s -msse -msse4 -mno-sse -mno-mmx -msse 2> %t
-// RUN: grep '"-target-feature" "+sse" "-target-feature" "+sse4" "-target-feature" "-sse" "-target-feature" "-mmx" "-target-feature" "+sse"' %t
-
+// RUN: grep '"pentium4" "-target-feature" "+sse4" "-target-feature" "-mmx" "-target-feature" "+sse"' %t
+// Note that we filter out all but the last -m(no)sse.