[PATCH] D107473: [LLVM][LTO][NFC] Resolve FIXME in ThinLTOCodeGenerator.cpp

Alf via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 4 08:59:24 PDT 2021


gAlfonso-bit created this revision.
gAlfonso-bit added a reviewer: LLVM.
Herald added subscribers: ormris, steven_wu, hiraditya, inglorion.
gAlfonso-bit requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Made the complicated if statements into a switch statement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107473

Files:
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp


Index: llvm/lib/LTO/ThinLTOCodeGenerator.cpp
===================================================================
--- llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -36,7 +36,6 @@
 #include "llvm/IR/Verifier.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/LTO/LTO.h"
-#include "llvm/LTO/SummaryBasedOptimizations.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Object/IRObjectFile.h"
 #include "llvm/Passes/PassBuilder.h"
@@ -47,7 +46,6 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/SHA1.h"
 #include "llvm/Support/SmallVectorMemoryBuffer.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/ThreadPool.h"
@@ -588,15 +586,19 @@
 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:
+    case llvm::Triple::aarch64_32:
       TMBuilder.MCpu = "cyclone";
+      break;
+    }
   }
   TMBuilder.TheTriple = std::move(TheTriple);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107473.364139.patch
Type: text/x-patch
Size: 1680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210804/7ebd1c6d/attachment.bin>


More information about the llvm-commits mailing list