[lld] 82de9bb - [lld-macho] Addressed additional post-commit comments from D126046

Vy Nguyen via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 3 12:48:34 PDT 2022


Author: Vy Nguyen
Date: 2022-06-03T15:48:11-04:00
New Revision: 82de9bb66bc6011d6281939d921b07957967b7c7

URL: https://github.com/llvm/llvm-project/commit/82de9bb66bc6011d6281939d921b07957967b7c7
DIFF: https://github.com/llvm/llvm-project/commit/82de9bb66bc6011d6281939d921b07957967b7c7.diff

LOG: [lld-macho] Addressed additional post-commit comments from  D126046

- fixed newlines
- renamed helper function for clarity
- added additional comment

Differential Revision: https://reviews.llvm.org/D126792

Added: 
    

Modified: 
    lld/MachO/Driver.cpp
    lld/MachO/SyntheticSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index c04c4fb1899bb..9e3ea8eedcfcc 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -938,8 +938,8 @@ bool SymbolPatterns::match(StringRef symbolName) const {
   return matchLiteral(symbolName) || matchGlob(symbolName);
 }
 
-static void handleSymbolPatternsListHelper(const Arg *arg,
-                                           SymbolPatterns &symbolPatterns) {
+static void parseSymbolPatternsFile(const Arg *arg,
+                                    SymbolPatterns &symbolPatterns) {
   StringRef path = arg->getValue();
   Optional<MemoryBufferRef> buffer = readFile(path);
   if (!buffer) {
@@ -953,6 +953,7 @@ static void handleSymbolPatternsListHelper(const Arg *arg,
       symbolPatterns.insert(line);
   }
 }
+
 static void handleSymbolPatterns(InputArgList &args,
                                  SymbolPatterns &symbolPatterns,
                                  unsigned singleOptionCode,
@@ -960,7 +961,7 @@ static void handleSymbolPatterns(InputArgList &args,
   for (const Arg *arg : args.filtered(singleOptionCode))
     symbolPatterns.insert(arg->getValue());
   for (const Arg *arg : args.filtered(listFileOptionCode))
-    handleSymbolPatternsListHelper(arg, symbolPatterns);
+    parseSymbolPatternsFile(arg, symbolPatterns);
 }
 
 static void createFiles(const InputArgList &args) {
@@ -1426,7 +1427,6 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
       switch (arg->getOption().getID()) {
       case OPT_x:
         config->localSymbolsPresence = SymtabPresence::None;
-
         break;
       case OPT_non_global_symbols_no_strip_list:
         if (excludeLocal) {
@@ -1435,7 +1435,7 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
         } else {
           includeLocal = true;
           config->localSymbolsPresence = SymtabPresence::SelectivelyIncluded;
-          handleSymbolPatternsListHelper(arg, config->localSymbolPatterns);
+          parseSymbolPatternsFile(arg, config->localSymbolPatterns);
         }
         break;
       case OPT_non_global_symbols_strip_list:
@@ -1445,7 +1445,7 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
         } else {
           excludeLocal = true;
           config->localSymbolsPresence = SymtabPresence::SelectivelyExcluded;
-          handleSymbolPatternsListHelper(arg, config->localSymbolPatterns);
+          parseSymbolPatternsFile(arg, config->localSymbolPatterns);
         }
         break;
       default:

diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 367586adaf5b1..db0b1e794488d 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -991,7 +991,9 @@ void SymtabSection::finalizeContents() {
 
   // Local symbols aren't in the SymbolTable, so we walk the list of object
   // files to gather them.
-  // But if `-x` is set, then we don't need to.
+  // But if `-x` is set, then we don't need to. localSymbolsHandler() will do
+  // the right thing regardless, but this check is a perf optimization because
+  // iterating through all the input files and their symbols is expensive.
   if (config->localSymbolsPresence != SymtabPresence::None) {
     for (const InputFile *file : inputFiles) {
       if (auto *objFile = dyn_cast<ObjFile>(file)) {


        


More information about the llvm-commits mailing list