verify-uselistorder: Make the verification logic easier to reuse
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 1 Aug 2014 22:52:06 +0000 (22:52 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 1 Aug 2014 22:52:06 +0000 (22:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214587 91177308-0d34-0410-b5e6-96231b3b80d8

tools/verify-uselistorder/verify-uselistorder.cpp

index a9666ac528490fe5226a1f6a0c58ae00848800bb..7b81b4f516c394860b6434c1793dbd20e4625ac1 100644 (file)
@@ -359,6 +359,15 @@ static bool verifyAssemblyUseListOrder(const Module &M) {
   return matches(ValueMapping(M), ValueMapping(*OtherM));
 }
 
   return matches(ValueMapping(M), ValueMapping(*OtherM));
 }
 
+static void verifyUseListOrder(const Module &M) {
+  if (!verifyBitcodeUseListOrder(M))
+    report_fatal_error("bitcode use-list order changed");
+
+  if (shouldPreserveAssemblyUseListOrder())
+    if (!verifyAssemblyUseListOrder(M))
+      report_fatal_error("assembly use-list order changed");
+}
+
 int main(int argc, char **argv) {
   sys::PrintStackTraceOnErrorSignal();
   llvm::PrettyStackTraceProgram X(argc, argv);
 int main(int argc, char **argv) {
   sys::PrintStackTraceOnErrorSignal();
   llvm::PrettyStackTraceProgram X(argc, argv);
@@ -397,12 +406,7 @@ int main(int argc, char **argv) {
     // Shuffle with a different seed each time so that use-lists that aren't
     // modified the first time are likely to be modified the next time.
     shuffleUseLists(*M, I);
     // Shuffle with a different seed each time so that use-lists that aren't
     // modified the first time are likely to be modified the next time.
     shuffleUseLists(*M, I);
-    if (!verifyBitcodeUseListOrder(*M))
-      report_fatal_error("bitcode use-list order changed");
-
-    if (shouldPreserveAssemblyUseListOrder())
-      if (!verifyAssemblyUseListOrder(*M))
-        report_fatal_error("assembly use-list order changed");
+    verifyUseListOrder(*M);
   }
 
   return 0;
   }
 
   return 0;