Skip to content

Commit 2602b66

Browse files
committed
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
1 parent fcfd562 commit 2602b66

File tree

13 files changed

+94
-42
lines changed

13 files changed

+94
-42
lines changed

include/llvm/InitializePasses.h

-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ void initializeUnifyFunctionExitNodesPass(PassRegistry&);
268268
void initializeUnreachableBlockElimPass(PassRegistry&);
269269
void initializeUnreachableMachineBlockElimPass(PassRegistry&);
270270
void initializeVerifierLegacyPassPass(PassRegistry&);
271-
void initializeVerifyUseListOrderPass(PassRegistry&);
272271
void initializeVirtRegMapPass(PassRegistry&);
273272
void initializeVirtRegRewriterPass(PassRegistry&);
274273
void initializeInstSimplifierPass(PassRegistry&);

include/llvm/LinkAllPasses.h

-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ namespace {
161161
(void) llvm::createPartiallyInlineLibCallsPass();
162162
(void) llvm::createScalarizerPass();
163163
(void) llvm::createSeparateConstOffsetFromGEPPass();
164-
(void) llvm::createVerifyUseListOrderPass();
165164

166165
(void)new llvm::IntervalPartition();
167166
(void)new llvm::FindUsedTypes();

include/llvm/Transforms/IPO.h

-5
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
118118
/// createInternalizePass - Same as above, but with an empty exportList.
119119
ModulePass *createInternalizePass();
120120

121-
/// \brief Verify that use-list order doesn't change after shuffling.
122-
///
123-
/// \note This is a transformation, since the use-list order changes.
124-
ModulePass *createVerifyUseListOrderPass();
125-
126121
//===----------------------------------------------------------------------===//
127122
/// createDeadArgEliminationPass - This pass removes arguments from functions
128123
/// which are not used by the body of the function.

lib/Transforms/IPO/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ add_llvm_library(LLVMipo
2020
PruneEH.cpp
2121
StripDeadPrototypes.cpp
2222
StripSymbols.cpp
23-
VerifyUseListOrder.cpp
2423
)
2524

2625
add_dependencies(LLVMipo intrinsics_gen)

lib/Transforms/IPO/IPO.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ void llvm::initializeIPO(PassRegistry &Registry) {
4444
initializeStripDebugDeclarePass(Registry);
4545
initializeStripDeadDebugInfoPass(Registry);
4646
initializeStripNonDebugSymbolsPass(Registry);
47-
initializeVerifyUseListOrderPass(Registry);
4847
initializeBarrierNoopPass(Registry);
4948
}
5049

test/Bitcode/use-list-order.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -S < %s -preserve-bc-use-list-order -verify-use-list-order
1+
; RUN: llvm-uselistorder < %s -preserve-bc-use-list-order
22
; XFAIL: *
33

44
@a = global [4 x i1] [i1 0, i1 1, i1 0, i1 1]

test/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ set(LLVM_TEST_DEPENDS
4444
llvm-rtdyld
4545
llvm-symbolizer
4646
llvm-tblgen
47+
llvm-uselistorder
4748
llvm-vtabledump
4849
macho-dump
4950
opt

test/lit.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ for pattern in [r"\bbugpoint\b(?!-)",
228228
r"\bllvm-rtdyld\b",
229229
r"\bllvm-size\b",
230230
r"\bllvm-tblgen\b",
231+
r"\bllvm-uselistorder\b",
231232
r"\bllvm-vtabledump\b",
232233
r"\bllvm-c-test\b",
233234
r"\bmacho-dump\b",

tools/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ add_llvm_tool_subdirectory(llvm-bcanalyzer)
4343
add_llvm_tool_subdirectory(llvm-stress)
4444
add_llvm_tool_subdirectory(llvm-mcmarkup)
4545

46+
add_llvm_tool_subdirectory(llvm-uselistorder)
47+
4648
add_llvm_tool_subdirectory(llvm-symbolizer)
4749

4850
add_llvm_tool_subdirectory(llvm-c-test)
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(LLVM_LINK_COMPONENTS
2+
Support
3+
IRReader
4+
BitWriter
5+
)
6+
7+
add_llvm_tool(llvm-uselistorder
8+
llvm-uselistorder.cpp
9+
)

tools/llvm-uselistorder/LLVMBuild.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
;===- ./tools/llvm-uselistorder/LLVMBuild.txt ------------------*- Conf -*--===;
2+
;
3+
; The LLVM Compiler Infrastructure
4+
;
5+
; This file is distributed under the University of Illinois Open Source
6+
; License. See LICENSE.TXT for details.
7+
;
8+
;===------------------------------------------------------------------------===;
9+
;
10+
; This is an LLVMBuild description file for the components in this subdirectory.
11+
;
12+
; For more information on the LLVMBuild system, please see:
13+
;
14+
; http://llvm.org/docs/LLVMBuild.html
15+
;
16+
;===------------------------------------------------------------------------===;
17+
18+
[component_0]
19+
type = Tool
20+
name = llvm-uselistorder
21+
parent = Tools
22+
required_libraries = IRReader BitWriter Support

tools/llvm-uselistorder/Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
##===- tools/llvm-uselistorder/Makefile --------------------*- Makefile -*-===##
2+
#
3+
# The LLVM Compiler Infrastructure
4+
#
5+
# This file is distributed under the University of Illinois Open Source
6+
# License. See LICENSE.TXT for details.
7+
#
8+
##===----------------------------------------------------------------------===##
9+
10+
LEVEL := ../..
11+
TOOLNAME := llvm-uselistorder
12+
LINK_COMPONENTS := support irreader bitwriter
13+
14+
# This tool has no plugins, optimize startup time.
15+
TOOL_NO_EXPORTS := 1
16+
17+
include $(LEVEL)/Makefile.common

lib/Transforms/IPO/VerifyUseListOrder.cpp renamed to tools/llvm-uselistorder/llvm-uselistorder.cpp

+41-32
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- VerifyUseListOrder.cpp - Use List Order Verifier ---------*- C++ -*-===//
1+
//===- opt.cpp - The LLVM Modular Optimizer -------------------------------===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -7,33 +7,39 @@
77
//
88
//===----------------------------------------------------------------------===//
99
//
10-
// Pass to verify use-list order doesn't change after serialization.
11-
//
12-
// Despite it being a verifier, this pass *does* transform the module, since it
13-
// shuffles the use-list of every value.
10+
// Optimizations may be specified an arbitrary number of times on the command
11+
// line, They are run in the order specified.
1412
//
1513
//===----------------------------------------------------------------------===//
1614

17-
#include "llvm/Transforms/IPO.h"
18-
1915
#include "llvm/ADT/DenseMap.h"
2016
#include "llvm/AsmParser/Parser.h"
2117
#include "llvm/Bitcode/ReaderWriter.h"
2218
#include "llvm/IR/LLVMContext.h"
2319
#include "llvm/IR/Module.h"
2420
#include "llvm/IR/UseListOrder.h"
25-
#include "llvm/Pass.h"
21+
#include "llvm/IRReader/IRReader.h"
22+
#include "llvm/Support/CommandLine.h"
2623
#include "llvm/Support/Debug.h"
2724
#include "llvm/Support/ErrorHandling.h"
2825
#include "llvm/Support/FileSystem.h"
2926
#include "llvm/Support/FileUtilities.h"
27+
#include "llvm/Support/ManagedStatic.h"
3028
#include "llvm/Support/MemoryBuffer.h"
29+
#include "llvm/Support/PrettyStackTrace.h"
30+
#include "llvm/Support/Signals.h"
3131
#include "llvm/Support/SourceMgr.h"
32+
#include "llvm/Support/SystemUtils.h"
3233

3334
using namespace llvm;
3435

3536
#define DEBUG_TYPE "use-list-order"
3637

38+
static cl::opt<std::string> InputFilename(cl::Positional,
39+
cl::desc("<input bitcode file>"),
40+
cl::init("-"),
41+
cl::value_desc("filename"));
42+
3743
namespace {
3844

3945
struct TempFile {
@@ -329,42 +335,45 @@ static bool verifyAssemblyUseListOrder(const Module &M) {
329335
return matches(ValueMapping(M), ValueMapping(*OtherM));
330336
}
331337

332-
namespace {
333-
class VerifyUseListOrder : public ModulePass {
334-
public:
335-
static char ID;
336-
VerifyUseListOrder();
337-
bool runOnModule(Module &M) override;
338-
};
339-
} // end anonymous namespace
338+
int main(int argc, char **argv) {
339+
sys::PrintStackTraceOnErrorSignal();
340+
llvm::PrettyStackTraceProgram X(argc, argv);
340341

341-
char VerifyUseListOrder::ID = 0;
342-
INITIALIZE_PASS(VerifyUseListOrder, "verify-use-list-order",
343-
"Verify Use List Order", false, false)
344-
VerifyUseListOrder::VerifyUseListOrder() : ModulePass(ID) {
345-
initializeVerifyUseListOrderPass(*PassRegistry::getPassRegistry());
346-
}
342+
// Enable debug stream buffering.
343+
EnableDebugBuffering = true;
344+
345+
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
346+
LLVMContext &Context = getGlobalContext();
347+
348+
cl::ParseCommandLineOptions(argc, argv,
349+
"llvm tool to verify use-list order\n");
350+
351+
SMDiagnostic Err;
352+
353+
// Load the input module...
354+
std::unique_ptr<Module> M;
355+
M.reset(ParseIRFile(InputFilename, Err, Context));
356+
357+
if (!M.get()) {
358+
Err.print(argv[0], errs());
359+
return 1;
360+
}
347361

348-
bool VerifyUseListOrder::runOnModule(Module &M) {
349362
DEBUG(dbgs() << "*** verify-use-list-order ***\n");
350363
if (!shouldPreserveBitcodeUseListOrder()) {
351364
// Can't verify if order isn't preserved.
352365
DEBUG(dbgs() << "warning: cannot verify bitcode; "
353366
"try -preserve-bc-use-list-order\n");
354-
return false;
367+
return 0;
355368
}
356369

357-
shuffleUseLists(M);
358-
if (!verifyBitcodeUseListOrder(M))
370+
shuffleUseLists(*M);
371+
if (!verifyBitcodeUseListOrder(*M))
359372
report_fatal_error("bitcode use-list order changed");
360373

361374
if (shouldPreserveBitcodeUseListOrder())
362-
if (!verifyAssemblyUseListOrder(M))
375+
if (!verifyAssemblyUseListOrder(*M))
363376
report_fatal_error("assembly use-list order changed");
364377

365-
return true;
366-
}
367-
368-
ModulePass *llvm::createVerifyUseListOrderPass() {
369-
return new VerifyUseListOrder;
378+
return 0;
370379
}

0 commit comments

Comments
 (0)