[PATCH] D148848: [BOLT] Remove unneeded dyncasts

Nathan Sidwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 21 10:41:23 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGffb42e313d54: [BOLT] Remove unneeded dyncasts (authored by urnathan).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148848/new/

https://reviews.llvm.org/D148848

Files:
  bolt/lib/Rewrite/RewriteInstance.cpp


Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -413,7 +413,7 @@
   NamedRegionTimer T("discoverStorage", "discover storage", TimerGroupName,
                      TimerGroupDesc, opts::TimeRewrite);
 
-  auto ELF64LEFile = dyn_cast<ELF64LEObjectFile>(InputFile);
+  auto ELF64LEFile = cast<ELF64LEObjectFile>(InputFile);
   const ELFFile<ELF64LE> &Obj = ELF64LEFile->getELFFile();
 
   BC->StartFunctionAddress = Obj.getHeader().e_entry;
@@ -4222,11 +4222,7 @@
 }
 
 void RewriteInstance::patchELFPHDRTable() {
-  auto ELF64LEFile = dyn_cast<ELF64LEObjectFile>(InputFile);
-  if (!ELF64LEFile) {
-    errs() << "BOLT-ERROR: only 64-bit LE ELF binaries are supported\n";
-    exit(1);
-  }
+  auto ELF64LEFile = cast<ELF64LEObjectFile>(InputFile);
   const ELFFile<ELF64LE> &Obj = ELF64LEFile->getELFFile();
   raw_fd_ostream &OS = Out->os();
 
@@ -4375,11 +4371,7 @@
 }
 
 void RewriteInstance::rewriteNoteSections() {
-  auto ELF64LEFile = dyn_cast<ELF64LEObjectFile>(InputFile);
-  if (!ELF64LEFile) {
-    errs() << "BOLT-ERROR: only 64-bit LE ELF binaries are supported\n";
-    exit(1);
-  }
+  auto ELF64LEFile = cast<ELF64LEObjectFile>(InputFile);
   const ELFFile<ELF64LE> &Obj = ELF64LEFile->getELFFile();
   raw_fd_ostream &OS = Out->os();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148848.515829.patch
Type: text/x-patch
Size: 1402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230421/25ee013a/attachment.bin>


More information about the llvm-commits mailing list