]> granicus.if.org Git - llvm/commitdiff
Move -verify-use-list-order into llvm-uselistorder
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 25 Jul 2014 17:13:03 +0000 (17:13 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 25 Jul 2014 17:13:03 +0000 (17:13 +0000)
Ugh.  Turns out not even transformation passes link in how to read IR.
I sincerely believe the buildbots will finally agree with my system
after this though.  (I don't really understand why all of this has been
working on my system, but not on all the buildbots.)

Create a new tool called llvm-uselistorder to use for verifying use-list
order.  For now, just dump everything from the (now defunct)
-verify-use-list-order pass into the tool.

This might be a better way to test use-list order anyway.

Part of PR5680.

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

13 files changed:
include/llvm/InitializePasses.h
include/llvm/LinkAllPasses.h
include/llvm/Transforms/IPO.h
lib/Transforms/IPO/CMakeLists.txt
lib/Transforms/IPO/IPO.cpp
test/Bitcode/use-list-order.ll
test/CMakeLists.txt
test/lit.cfg
tools/CMakeLists.txt
tools/llvm-uselistorder/CMakeLists.txt [new file with mode: 0644]
tools/llvm-uselistorder/LLVMBuild.txt [new file with mode: 0644]
tools/llvm-uselistorder/Makefile [new file with mode: 0644]
tools/llvm-uselistorder/llvm-uselistorder.cpp [moved from lib/Transforms/IPO/VerifyUseListOrder.cpp with 87% similarity]

index ae036b462ab2e6ed82bca2bc5dcd4266be6bf9da..20074f0a5d5df42c5f7300831815370fc0ae5d3a 100644 (file)
@@ -268,7 +268,6 @@ void initializeUnifyFunctionExitNodesPass(PassRegistry&);
 void initializeUnreachableBlockElimPass(PassRegistry&);
 void initializeUnreachableMachineBlockElimPass(PassRegistry&);
 void initializeVerifierLegacyPassPass(PassRegistry&);
-void initializeVerifyUseListOrderPass(PassRegistry&);
 void initializeVirtRegMapPass(PassRegistry&);
 void initializeVirtRegRewriterPass(PassRegistry&);
 void initializeInstSimplifierPass(PassRegistry&);
index ec695c8b79cdbbbaf99540ef718e86078dcf0f54..b7f832dcee9986e8ea52b319b155731dfc67298d 100644 (file)
@@ -161,7 +161,6 @@ namespace {
       (void) llvm::createPartiallyInlineLibCallsPass();
       (void) llvm::createScalarizerPass();
       (void) llvm::createSeparateConstOffsetFromGEPPass();
-      (void) llvm::createVerifyUseListOrderPass();
 
       (void)new llvm::IntervalPartition();
       (void)new llvm::FindUsedTypes();
index ca6d5144fc41261b6782c4bbabd2e017a520cd76..ce1a7d6a5230a3ca4e7c409bd9a1d75a4a79d3d6 100644 (file)
@@ -118,11 +118,6 @@ ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
 /// createInternalizePass - Same as above, but with an empty exportList.
 ModulePass *createInternalizePass();
 
-/// \brief Verify that use-list order doesn't change after shuffling.
-///
-/// \note This is a transformation, since the use-list order changes.
-ModulePass *createVerifyUseListOrderPass();
-
 //===----------------------------------------------------------------------===//
 /// createDeadArgEliminationPass - This pass removes arguments from functions
 /// which are not used by the body of the function.
index 070ecfdc1437071ed78e2f13d8336ca3532ed9b0..90c1c33e6dca7945ac9d040b5bd4e903253c6240 100644 (file)
@@ -20,7 +20,6 @@ add_llvm_library(LLVMipo
   PruneEH.cpp
   StripDeadPrototypes.cpp
   StripSymbols.cpp
-  VerifyUseListOrder.cpp
   )
 
 add_dependencies(LLVMipo intrinsics_gen)
index 5dce2d6b407a7d0f8f6eedb00242b0cfed26163c..b4d31d8d6fc25b85fb0a4bd8c48f522d830f760a 100644 (file)
@@ -44,7 +44,6 @@ void llvm::initializeIPO(PassRegistry &Registry) {
   initializeStripDebugDeclarePass(Registry);
   initializeStripDeadDebugInfoPass(Registry);
   initializeStripNonDebugSymbolsPass(Registry);
-  initializeVerifyUseListOrderPass(Registry);
   initializeBarrierNoopPass(Registry);
 }
 
index 6d87dedee5171c5b96e58ce3e3cdb3294d24a2fd..aef526403c6acbe4a471dd04b515ff79c267f809 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S < %s -preserve-bc-use-list-order -verify-use-list-order
+; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order
 ; XFAIL: *
 
 @a = global [4 x i1] [i1 0, i1 1, i1 0, i1 1]
index 928b87a778cc04df7f9db384152d5503ea85bad3..59a17b1950680d1481bcd622076fa84b6fa08593 100644 (file)
@@ -44,6 +44,7 @@ set(LLVM_TEST_DEPENDS
           llvm-rtdyld
           llvm-symbolizer
           llvm-tblgen
+          llvm-uselistorder
           llvm-vtabledump
           macho-dump
           opt
index 99c05a794893ab8d4252e77f6bf6d6bc468247f2..2b9b2d9a7d05b2f137892aa02f2ddbc5114f8087 100644 (file)
@@ -228,6 +228,7 @@ for pattern in [r"\bbugpoint\b(?!-)",
                 r"\bllvm-rtdyld\b",
                 r"\bllvm-size\b",
                 r"\bllvm-tblgen\b",
+                r"\bllvm-uselistorder\b",
                 r"\bllvm-vtabledump\b",
                 r"\bllvm-c-test\b",
                 r"\bmacho-dump\b",
index acc4eb12860ee07ab0f4da7b89fcf84eba73325a..ef8095b688e1cf17654a08160b93b8e4a1bd3807 100644 (file)
@@ -43,6 +43,8 @@ add_llvm_tool_subdirectory(llvm-bcanalyzer)
 add_llvm_tool_subdirectory(llvm-stress)
 add_llvm_tool_subdirectory(llvm-mcmarkup)
 
+add_llvm_tool_subdirectory(llvm-uselistorder)
+
 add_llvm_tool_subdirectory(llvm-symbolizer)
 
 add_llvm_tool_subdirectory(llvm-c-test)
diff --git a/tools/llvm-uselistorder/CMakeLists.txt b/tools/llvm-uselistorder/CMakeLists.txt
new file mode 100644 (file)
index 0000000..21c46e9
--- /dev/null
@@ -0,0 +1,9 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  IRReader
+  BitWriter
+  )
+
+add_llvm_tool(llvm-uselistorder
+  llvm-uselistorder.cpp
+  )
diff --git a/tools/llvm-uselistorder/LLVMBuild.txt b/tools/llvm-uselistorder/LLVMBuild.txt
new file mode 100644 (file)
index 0000000..b9d6f10
--- /dev/null
@@ -0,0 +1,22 @@
+;===- ./tools/llvm-uselistorder/LLVMBuild.txt ------------------*- Conf -*--===;
+;
+;                     The LLVM Compiler Infrastructure
+;
+; This file is distributed under the University of Illinois Open Source
+; License. See LICENSE.TXT for details.
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+;   http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[component_0]
+type = Tool
+name = llvm-uselistorder
+parent = Tools
+required_libraries = IRReader BitWriter Support
diff --git a/tools/llvm-uselistorder/Makefile b/tools/llvm-uselistorder/Makefile
new file mode 100644 (file)
index 0000000..b9fc34b
--- /dev/null
@@ -0,0 +1,17 @@
+##===- tools/llvm-uselistorder/Makefile --------------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL := ../..
+TOOLNAME := llvm-uselistorder
+LINK_COMPONENTS := support irreader bitwriter
+
+# This tool has no plugins, optimize startup time.
+TOOL_NO_EXPORTS := 1
+
+include $(LEVEL)/Makefile.common
similarity index 87%
rename from lib/Transforms/IPO/VerifyUseListOrder.cpp
rename to tools/llvm-uselistorder/llvm-uselistorder.cpp
index 16a88e3d9a19524894d31e1b095a3a6f0712419b..1d5a3d9ba2809d82d1adea62ba1e6f8d2906f378 100644 (file)
@@ -1,4 +1,4 @@
-//===- VerifyUseListOrder.cpp - Use List Order Verifier ---------*- C++ -*-===//
+//===- opt.cpp - The LLVM Modular Optimizer -------------------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,33 +7,39 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// Pass to verify use-list order doesn't change after serialization.
-//
-// Despite it being a verifier, this pass *does* transform the module, since it
-// shuffles the use-list of every value.
+// Optimizations may be specified an arbitrary number of times on the command
+// line, They are run in the order specified.
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Transforms/IPO.h"
-
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/AsmParser/Parser.h"
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/UseListOrder.h"
-#include "llvm/Pass.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Signals.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/SystemUtils.h"
 
 using namespace llvm;
 
 #define DEBUG_TYPE "use-list-order"
 
+static cl::opt<std::string> InputFilename(cl::Positional,
+                                          cl::desc("<input bitcode file>"),
+                                          cl::init("-"),
+                                          cl::value_desc("filename"));
+
 namespace {
 
 struct TempFile {
@@ -329,42 +335,45 @@ static bool verifyAssemblyUseListOrder(const Module &M) {
   return matches(ValueMapping(M), ValueMapping(*OtherM));
 }
 
-namespace {
-class VerifyUseListOrder : public ModulePass {
-public:
-  static char ID;
-  VerifyUseListOrder();
-  bool runOnModule(Module &M) override;
-};
-} // end anonymous namespace
+int main(int argc, char **argv) {
+  sys::PrintStackTraceOnErrorSignal();
+  llvm::PrettyStackTraceProgram X(argc, argv);
 
-char VerifyUseListOrder::ID = 0;
-INITIALIZE_PASS(VerifyUseListOrder, "verify-use-list-order",
-                "Verify Use List Order", false, false)
-VerifyUseListOrder::VerifyUseListOrder() : ModulePass(ID) {
-  initializeVerifyUseListOrderPass(*PassRegistry::getPassRegistry());
-}
+  // Enable debug stream buffering.
+  EnableDebugBuffering = true;
+
+  llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+  LLVMContext &Context = getGlobalContext();
+
+  cl::ParseCommandLineOptions(argc, argv,
+                              "llvm tool to verify use-list order\n");
+
+  SMDiagnostic Err;
+
+  // Load the input module...
+  std::unique_ptr<Module> M;
+  M.reset(ParseIRFile(InputFilename, Err, Context));
+
+  if (!M.get()) {
+    Err.print(argv[0], errs());
+    return 1;
+  }
 
-bool VerifyUseListOrder::runOnModule(Module &M) {
   DEBUG(dbgs() << "*** verify-use-list-order ***\n");
   if (!shouldPreserveBitcodeUseListOrder()) {
     // Can't verify if order isn't preserved.
     DEBUG(dbgs() << "warning: cannot verify bitcode; "
                     "try -preserve-bc-use-list-order\n");
-    return false;
+    return 0;
   }
 
-  shuffleUseLists(M);
-  if (!verifyBitcodeUseListOrder(M))
+  shuffleUseLists(*M);
+  if (!verifyBitcodeUseListOrder(*M))
     report_fatal_error("bitcode use-list order changed");
 
   if (shouldPreserveBitcodeUseListOrder())
-    if (!verifyAssemblyUseListOrder(M))
+    if (!verifyAssemblyUseListOrder(*M))
       report_fatal_error("assembly use-list order changed");
 
-  return true;
-}
-
-ModulePass *llvm::createVerifyUseListOrderPass() {
-  return new VerifyUseListOrder;
+  return 0;
 }