llvm-lto: Re-order code.
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 21 Aug 2015 19:09:42 +0000 (19:09 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 21 Aug 2015 19:09:42 +0000 (19:09 +0000)
This saves us from needing to asave a pointer, and will be needed for an
upcoming ownership change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245722 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-lto/llvm-lto.cpp

index 9678c8397e0e1688eb5c0ff797b35e01922f4311..7f87859f3b23f8b04555e8c442bf3c0fb91eafcb 100644 (file)
@@ -207,7 +207,16 @@ int main(int argc, char **argv) {
       return 1;
     }
 
-    LTOModule *LTOMod = Module.get();
+    unsigned NumSyms = Module->getSymbolCount();
+    for (unsigned I = 0; I < NumSyms; ++I) {
+      StringRef Name = Module->getSymbolName(I);
+      if (!DSOSymbolsSet.count(Name))
+        continue;
+      lto_symbol_attributes Attrs = Module->getSymbolAttributes(I);
+      unsigned Scope = Attrs & LTO_SYMBOL_SCOPE_MASK;
+      if (Scope != LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN)
+        KeptDSOSyms.push_back(Name);
+    }
 
     // We use the first input module as the destination module when
     // SetMergedModule is true.
@@ -216,17 +225,6 @@ int main(int argc, char **argv) {
       CodeGen.setModule(Module.release());
     } else if (!CodeGen.addModule(Module.get()))
       return 1;
-
-    unsigned NumSyms = LTOMod->getSymbolCount();
-    for (unsigned I = 0; I < NumSyms; ++I) {
-      StringRef Name = LTOMod->getSymbolName(I);
-      if (!DSOSymbolsSet.count(Name))
-        continue;
-      lto_symbol_attributes Attrs = LTOMod->getSymbolAttributes(I);
-      unsigned Scope = Attrs & LTO_SYMBOL_SCOPE_MASK;
-      if (Scope != LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN)
-        KeptDSOSyms.push_back(Name);
-    }
   }
 
   // Add all the exported symbols to the table of symbols to preserve.