Mercurial > hg > CbC > CbC_llvm
diff tools/verify-uselistorder/verify-uselistorder.cpp @ 148:63bd29f05246
merged
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 19:46:37 +0900 |
parents | c2174574ed3a |
children |
line wrap: on
line diff
--- a/tools/verify-uselistorder/verify-uselistorder.cpp Sun Dec 23 19:23:36 2018 +0900 +++ b/tools/verify-uselistorder/verify-uselistorder.cpp Wed Aug 14 19:46:37 2019 +0900 @@ -1,9 +1,8 @@ //===- verify-uselistorder.cpp - The LLVM Modular Optimizer ---------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -42,10 +41,8 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FileUtilities.h" -#include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/InitLLVM.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" #include "llvm/Support/raw_ostream.h" @@ -85,7 +82,7 @@ DenseMap<const Value *, unsigned> IDs; std::vector<const Value *> Values; - /// \brief Construct a value mapping for module. + /// Construct a value mapping for module. /// /// Creates mapping from every value in \c M to an ID. This mapping includes /// un-referencable values. @@ -98,7 +95,7 @@ /// mapping, but others -- which wouldn't be serialized -- are not. ValueMapping(const Module &M); - /// \brief Map a value. + /// Map a value. /// /// Maps a value. If it's a constant, maps all of its operands first. void map(const Value *V); @@ -109,7 +106,7 @@ bool TempFile::init(const std::string &Ext) { SmallVector<char, 64> Vector; - DEBUG(dbgs() << " - create-temp-file\n"); + LLVM_DEBUG(dbgs() << " - create-temp-file\n"); if (auto EC = sys::fs::createTemporaryFile("uselistorder", Ext, Vector)) { errs() << "verify-uselistorder: error: " << EC.message() << "\n"; return true; @@ -124,9 +121,9 @@ } bool TempFile::writeBitcode(const Module &M) const { - DEBUG(dbgs() << " - write bitcode\n"); + LLVM_DEBUG(dbgs() << " - write bitcode\n"); std::error_code EC; - raw_fd_ostream OS(Filename, EC, sys::fs::F_None); + raw_fd_ostream OS(Filename, EC, sys::fs::OF_None); if (EC) { errs() << "verify-uselistorder: error: " << EC.message() << "\n"; return true; @@ -137,9 +134,9 @@ } bool TempFile::writeAssembly(const Module &M) const { - DEBUG(dbgs() << " - write assembly\n"); + LLVM_DEBUG(dbgs() << " - write assembly\n"); std::error_code EC; - raw_fd_ostream OS(Filename, EC, sys::fs::F_Text); + raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text); if (EC) { errs() << "verify-uselistorder: error: " << EC.message() << "\n"; return true; @@ -150,7 +147,7 @@ } std::unique_ptr<Module> TempFile::readBitcode(LLVMContext &Context) const { - DEBUG(dbgs() << " - read bitcode\n"); + LLVM_DEBUG(dbgs() << " - read bitcode\n"); ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOr = MemoryBuffer::getFile(Filename); if (!BufferOr) { @@ -171,7 +168,7 @@ } std::unique_ptr<Module> TempFile::readAssembly(LLVMContext &Context) const { - DEBUG(dbgs() << " - read assembly\n"); + LLVM_DEBUG(dbgs() << " - read assembly\n"); SMDiagnostic Err; std::unique_ptr<Module> M = parseAssemblyFile(Filename, Err, Context); if (!M.get()) @@ -290,9 +287,9 @@ #endif static bool matches(const ValueMapping &LM, const ValueMapping &RM) { - DEBUG(dbgs() << "compare value maps\n"); + LLVM_DEBUG(dbgs() << "compare value maps\n"); if (LM.Values.size() != RM.Values.size()) { - DEBUG(debugSizeMismatch(LM, RM)); + LLVM_DEBUG(debugSizeMismatch(LM, RM)); return false; } @@ -319,22 +316,22 @@ while (LU != LE) { if (RU == RE) { - DEBUG(debugUserMismatch(LM, RM, I)); + LLVM_DEBUG(debugUserMismatch(LM, RM, I)); return false; } if (LM.lookup(LU->getUser()) != RM.lookup(RU->getUser())) { - DEBUG(debugUserMismatch(LM, RM, I)); + LLVM_DEBUG(debugUserMismatch(LM, RM, I)); return false; } if (LU->getOperandNo() != RU->getOperandNo()) { - DEBUG(debugUserMismatch(LM, RM, I)); + LLVM_DEBUG(debugUserMismatch(LM, RM, I)); return false; } skipUnmappedUsers(++LU, LE, LM); skipUnmappedUsers(++RU, RE, RM); } if (RU != RE) { - DEBUG(debugUserMismatch(LM, RM, I)); + LLVM_DEBUG(debugUserMismatch(LM, RM, I)); return false; } } @@ -399,7 +396,7 @@ // Generate random numbers between 10 and 99, which will line up nicely in // debug output. We're not worried about collisons here. - DEBUG(dbgs() << "V = "; V->dump()); + LLVM_DEBUG(dbgs() << "V = "; V->dump()); std::uniform_int_distribution<short> Dist(10, 99); SmallDenseMap<const Use *, short, 16> Order; auto compareUses = @@ -408,16 +405,16 @@ for (const Use &U : V->uses()) { auto I = Dist(Gen); Order[&U] = I; - DEBUG(dbgs() << " - order: " << I << ", op = " << U.getOperandNo() - << ", U = "; - U.getUser()->dump()); + LLVM_DEBUG(dbgs() << " - order: " << I << ", op = " << U.getOperandNo() + << ", U = "; + U.getUser()->dump()); } } while (std::is_sorted(V->use_begin(), V->use_end(), compareUses)); - DEBUG(dbgs() << " => shuffle\n"); + LLVM_DEBUG(dbgs() << " => shuffle\n"); V->sortUseList(compareUses); - DEBUG({ + LLVM_DEBUG({ for (const Use &U : V->uses()) { dbgs() << " - order: " << Order.lookup(&U) << ", op = " << U.getOperandNo() << ", U = "; @@ -439,7 +436,7 @@ // Nothing to shuffle for 0 or 1 users. return; - DEBUG({ + LLVM_DEBUG({ dbgs() << "V = "; V->dump(); for (const Use &U : V->uses()) { @@ -451,7 +448,7 @@ V->reverseUseList(); - DEBUG({ + LLVM_DEBUG({ for (const Use &U : V->uses()) { dbgs() << " - order: op = " << U.getOperandNo() << ", U = "; U.getUser()->dump(); @@ -517,23 +514,21 @@ std::minstd_rand0 Gen(std::minstd_rand0::default_seed + SeedOffset); DenseSet<Value *> Seen; changeUseLists(M, [&](Value *V) { shuffleValueUseLists(V, Gen, Seen); }); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); } static void reverseUseLists(Module &M) { DenseSet<Value *> Seen; changeUseLists(M, [&](Value *V) { reverseValueUseLists(V, Seen); }); - DEBUG(dbgs() << "\n"); + LLVM_DEBUG(dbgs() << "\n"); } int main(int argc, char **argv) { - sys::PrintStackTraceOnErrorSignal(argv[0]); - llvm::PrettyStackTraceProgram X(argc, argv); + InitLLVM X(argc, argv); // Enable debug stream buffering. EnableDebugBuffering = true; - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. LLVMContext Context; cl::ParseCommandLineOptions(argc, argv,