Index: llvm/lib/Target/SystemZ/SystemZSubtarget.h =================================================================== --- llvm/lib/Target/SystemZ/SystemZSubtarget.h +++ llvm/lib/Target/SystemZ/SystemZSubtarget.h @@ -84,12 +84,14 @@ std::unique_ptr FrameLowering; SystemZSubtarget &initializeSubtargetDependencies(StringRef CPU, + StringRef TuneCPU, StringRef FS); SystemZCallingConventionRegisters *initializeSpecialRegisters(); public: SystemZSubtarget(const Triple &TT, const std::string &CPU, - const std::string &FS, const TargetMachine &TM); + const std::string &TuneCPU, const std::string &FS, + const TargetMachine &TM); SystemZCallingConventionRegisters *getSpecialRegisters() const { assert(SpecialRegisters && "Unsupported SystemZ calling convention"); Index: llvm/lib/Target/SystemZ/SystemZSubtarget.cpp =================================================================== --- llvm/lib/Target/SystemZ/SystemZSubtarget.cpp +++ llvm/lib/Target/SystemZ/SystemZSubtarget.cpp @@ -27,13 +27,14 @@ // Pin the vtable to this file. void SystemZSubtarget::anchor() {} -SystemZSubtarget & -SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { - StringRef CPUName = CPU; - if (CPUName.empty()) - CPUName = "generic"; +SystemZSubtarget &SystemZSubtarget::initializeSubtargetDependencies( + StringRef CPU, StringRef TuneCPU, StringRef FS) { + if (CPU.empty()) + CPU = "generic"; + if (TuneCPU.empty()) + TuneCPU = CPU; // Parse features string. - ParseSubtargetFeatures(CPUName, /*TuneCPU*/ CPUName, FS); + ParseSubtargetFeatures(CPU, TuneCPU, FS); // -msoft-float implies -mno-vx. if (HasSoftFloat) @@ -64,9 +65,10 @@ } SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU, + const std::string &TuneCPU, const std::string &FS, const TargetMachine &TM) - : SystemZGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), + : SystemZGenSubtargetInfo(TT, CPU, TuneCPU, FS), HasDistinctOps(false), HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false), HasPopulationCount(false), HasMessageSecurityAssist3(false), HasMessageSecurityAssist4(false), @@ -88,8 +90,8 @@ HasResetDATProtection(false), HasProcessorActivityInstrumentation(false), HasSoftFloat(false), TargetTriple(TT), SpecialRegisters(initializeSpecialRegisters()), - InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this), - FrameLowering(SystemZFrameLowering::create(*this)) {} + InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)), + TLInfo(TM, *this), FrameLowering(SystemZFrameLowering::create(*this)) {} bool SystemZSubtarget::enableSubRegLiveness() const { return UseSubRegLiveness; Index: llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp =================================================================== --- llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp +++ llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp @@ -187,10 +187,13 @@ const SystemZSubtarget * SystemZTargetMachine::getSubtargetImpl(const Function &F) const { Attribute CPUAttr = F.getFnAttribute("target-cpu"); + Attribute TuneAttr = F.getFnAttribute("tune-cpu"); Attribute FSAttr = F.getFnAttribute("target-features"); std::string CPU = CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU; + std::string TuneCPU = + TuneAttr.isValid() ? TuneAttr.getValueAsString().str() : CPU; std::string FS = FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS; @@ -202,13 +205,14 @@ if (softFloat) FS += FS.empty() ? "+soft-float" : ",+soft-float"; - auto &I = SubtargetMap[CPU + FS]; + auto &I = SubtargetMap[CPU + TuneCPU + FS]; if (!I) { // This needs to be done before we create a new subtarget since any // creation will depend on the TM and the code generation flags on the // function that reside in TargetOptions. resetTargetOptions(F); - I = std::make_unique(TargetTriple, CPU, FS, *this); + I = std::make_unique(TargetTriple, CPU, TuneCPU, FS, + *this); } return I.get();