Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -1544,6 +1544,10 @@ } } +static void getTargetFeatureList(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, + std::vector &Names, bool ForAS); + static void AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args, ArgStringList &CmdArgs) { // Tell the linker to load the plugin. This has to come before AddLinkerInputs @@ -1560,6 +1564,20 @@ std::string CPU = getCPUName(Args, ToolChain.getTriple()); if (!CPU.empty()) CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=mcpu=") + CPU)); + + std::vector Names; + getTargetFeatureList(ToolChain.getDriver(), ToolChain.getTriple(), Args, + Names, false); + + if (!Names.empty()) { + std::string List; + for (unsigned i = 0; i < Names.size() - 1; ++i) { + List.append(Names[i]); + List.append(","); + } + List.append(Names[Names.size() - 1]); + CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=-mattr=") + List)); + } } static void getX86TargetFeatures(const Driver & D, @@ -1855,10 +1873,11 @@ } } -static void getTargetFeatures(const Driver &D, const llvm::Triple &Triple, - const ArgList &Args, ArgStringList &CmdArgs, - bool ForAS) { +static void getTargetFeatureList(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, + std::vector &Names, bool ForAS) { std::vector Features; + switch (Triple.getArch()) { default: break; @@ -1911,9 +1930,19 @@ unsigned Last = LastI->second; if (Last != I) continue; + Names.push_back(Name); + } +} + +static void getTargetFeatures(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args, ArgStringList &CmdArgs, + bool ForAs) { + std::vector Names; + getTargetFeatureList(D, Triple, Args, Names, ForAs); + for (unsigned i = 0; i < Names.size(); i++) { CmdArgs.push_back("-target-feature"); - CmdArgs.push_back(Name); + CmdArgs.push_back(Names[i]); } }