Move -verify-use-list-order into llvm-uselistorder

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
This commit is contained in:
Duncan P. N. Exon Smith 2014-07-25 17:13:03 +00:00
parent fcfd56262b
commit 2602b66b91
13 changed files with 94 additions and 42 deletions

View 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&);

View 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();

View 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.

View File

@ -20,7 +20,6 @@ add_llvm_library(LLVMipo
PruneEH.cpp
StripDeadPrototypes.cpp
StripSymbols.cpp
VerifyUseListOrder.cpp
)
add_dependencies(LLVMipo intrinsics_gen)

View File

@ -44,7 +44,6 @@ void llvm::initializeIPO(PassRegistry &Registry) {
initializeStripDebugDeclarePass(Registry);
initializeStripDeadDebugInfoPass(Registry);
initializeStripNonDebugSymbolsPass(Registry);
initializeVerifyUseListOrderPass(Registry);
initializeBarrierNoopPass(Registry);
}

View 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]

View File

@ -44,6 +44,7 @@ set(LLVM_TEST_DEPENDS
llvm-rtdyld
llvm-symbolizer
llvm-tblgen
llvm-uselistorder
llvm-vtabledump
macho-dump
opt

View 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",

View 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)

View File

@ -0,0 +1,9 @@
set(LLVM_LINK_COMPONENTS
Support
IRReader
BitWriter
)
add_llvm_tool(llvm-uselistorder
llvm-uselistorder.cpp
)

View File

@ -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

View File

@ -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

View 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;
}