[PATCH] D67310: [ELF][AArch64] Apply some NFC cleanups to AArch64ErrataFix.cpp

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 20:38:14 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: grimar, peter.smith, ruiu.
Herald added subscribers: llvm-commits, kristof.beyls, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D67310

Files:
  ELF/AArch64ErrataFix.cpp


Index: ELF/AArch64ErrataFix.cpp
===================================================================
--- ELF/AArch64ErrataFix.cpp
+++ ELF/AArch64ErrataFix.cpp
@@ -48,8 +48,8 @@
 using namespace llvm::support;
 using namespace llvm::support::endian;
 
-using namespace lld;
-using namespace lld::elf;
+namespace lld {
+namespace elf {
 
 // Helper functions to identify instructions and conditions needed to trigger
 // the Cortex-A53-843419 erratum.
@@ -374,7 +374,7 @@
   return patchOff;
 }
 
-class lld::elf::Patch843419Section : public SyntheticSection {
+class Patch843419Section : public SyntheticSection {
 public:
   Patch843419Section(InputSection *p, uint64_t off);
 
@@ -392,7 +392,7 @@
   Symbol *patchSym;
 };
 
-lld::elf::Patch843419Section::Patch843419Section(InputSection *p, uint64_t off)
+Patch843419Section::Patch843419Section(InputSection *p, uint64_t off)
     : SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 4,
                        ".text.patch"),
       patchee(p), patcheeOffset(off) {
@@ -403,11 +403,11 @@
   addSyntheticLocal(saver.save("$x"), STT_NOTYPE, 0, 0, *this);
 }
 
-uint64_t lld::elf::Patch843419Section::getLDSTAddr() const {
+uint64_t Patch843419Section::getLDSTAddr() const {
   return patchee->getVA(patcheeOffset);
 }
 
-void lld::elf::Patch843419Section::writeTo(uint8_t *buf) {
+void Patch843419Section::writeTo(uint8_t *buf) {
   // Copy the instruction that we will be replacing with a branch in the
   // Patchee Section.
   write32le(buf, read32le(patchee->data().begin() + patcheeOffset));
@@ -435,10 +435,10 @@
   // [Symbol Value, End of section). The type, code or data, is determined by
   // the mapping symbol name, $x for code, $d for data.
   auto isCodeMapSymbol = [](const Symbol *b) {
-    return b->getName() == "$x" || b->getName().startswith("$x.");
+    return b->getName().startswith("$x");
   };
   auto isDataMapSymbol = [](const Symbol *b) {
-    return b->getName() == "$d" || b->getName().startswith("$d.");
+    return b->getName().startswith("$d");
   };
 
   // Collect mapping symbols for every executable InputSection.
@@ -461,8 +461,6 @@
   // $d.0 $d.1 $x.1.
   for (auto &kv : sectionMap) {
     std::vector<const Defined *> &mapSyms = kv.second;
-    if (mapSyms.size() <= 1)
-      continue;
     llvm::stable_sort(mapSyms, [](const Defined *a, const Defined *b) {
       return a->value < b->value;
     });
@@ -630,7 +628,7 @@
 // Ouptut and Input Sections may have been changed.
 // Returns false if no patches were required and no changes were made.
 bool AArch64Err843419Patcher::createFixes() {
-  if (initialized == false)
+  if (!initialized)
     init();
 
   bool addressesChanged = false;
@@ -649,3 +647,5 @@
   }
   return addressesChanged;
 }
+} // namespace elf
+} // namespace lld


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67310.219220.patch
Type: text/x-patch
Size: 2790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190907/447f3fd7/attachment.bin>


More information about the llvm-commits mailing list