Index: llvm/lib/LTO/LTOCodeGenerator.cpp =================================================================== --- llvm/lib/LTO/LTOCodeGenerator.cpp +++ llvm/lib/LTO/LTOCodeGenerator.cpp @@ -339,15 +339,21 @@ FeatureStr = Features.getString(); // Set a default CPU for Darwin triples. if (Config.CPU.empty() && Triple.isOSDarwin()) { - if (Triple.getArch() == llvm::Triple::x86_64) + switch (Triple.getArch()) { + case llvm::Triple::x86_64: Config.CPU = "core2"; - else if (Triple.getArch() == llvm::Triple::x86) + break; + case llvm::Triple::x86: Config.CPU = "yonah"; - else if (Triple.isArm64e()) - Config.CPU = "apple-a12"; - else if (Triple.getArch() == llvm::Triple::aarch64 || - Triple.getArch() == llvm::Triple::aarch64_32) + break; + case llvm::Triple::aarch64: + if (Triple.isArm64e()) + Config.CPU = "apple-a12"; + LLVM_FALLTHROUGH; + case llvm::Triple::aarch64_32: Config.CPU = "cyclone"; + break; + } } TargetMach = createTargetMachine(); Index: llvm/lib/LTO/ThinLTOCodeGenerator.cpp =================================================================== --- llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -588,15 +588,22 @@ static void initTMBuilder(TargetMachineBuilder &TMBuilder, const Triple &TheTriple) { // Set a default CPU for Darwin triples (copied from LTOCodeGenerator). - // FIXME this looks pretty terrible... if (TMBuilder.MCpu.empty() && TheTriple.isOSDarwin()) { - if (TheTriple.getArch() == llvm::Triple::x86_64) + switch (TheTriple.getArch()) { + case llvm::Triple::x86_64: TMBuilder.MCpu = "core2"; - else if (TheTriple.getArch() == llvm::Triple::x86) + break; + case llvm::Triple::x86: TMBuilder.MCpu = "yonah"; - else if (TheTriple.getArch() == llvm::Triple::aarch64 || - TheTriple.getArch() == llvm::Triple::aarch64_32) + break; + case llvm::Triple::aarch64: + if (TheTriple.isArm64e()) + TMBuilder.MCpu = "apple-a12"; + LLVM_FALLTHROUGH; + case llvm::Triple::aarch64_32: TMBuilder.MCpu = "cyclone"; + break; + } } TMBuilder.TheTriple = std::move(TheTriple); }