diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2025-03-05 13:38:11 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2025-03-05 13:49:53 +0300 |
commit | 9eed360f02de773a5ed2de5d2a3e81fc7f06acfa (patch) | |
tree | 744a4054e64eb443073c7c6ad36b29cedcf9c2e6 /contrib/libs/llvm14/tools/llvm-diff/llvm-diff.cpp | |
parent | c141a5c40bda2eed1a68b0626ffdae5fd19359a6 (diff) | |
download | ydb-9eed360f02de773a5ed2de5d2a3e81fc7f06acfa.tar.gz |
Intermediate changes
commit_hash:2ec2671384dd8e604d41bc5c52c2f7858e4afea6
Diffstat (limited to 'contrib/libs/llvm14/tools/llvm-diff/llvm-diff.cpp')
-rw-r--r-- | contrib/libs/llvm14/tools/llvm-diff/llvm-diff.cpp | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/contrib/libs/llvm14/tools/llvm-diff/llvm-diff.cpp b/contrib/libs/llvm14/tools/llvm-diff/llvm-diff.cpp deleted file mode 100644 index 7349469c80d..00000000000 --- a/contrib/libs/llvm14/tools/llvm-diff/llvm-diff.cpp +++ /dev/null @@ -1,96 +0,0 @@ -//===-- llvm-diff.cpp - Module comparator command-line driver ---*- C++ -*-===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// This file defines the command-line driver for the difference engine. -// -//===----------------------------------------------------------------------===// - -#include "lib/DiffLog.h" -#include "lib/DifferenceEngine.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/IR/LLVMContext.h" -#include "llvm/IR/Module.h" -#include "llvm/IR/Type.h" -#include "llvm/IRReader/IRReader.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/SourceMgr.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Support/WithColor.h" -#include <string> -#include <utility> - - -using namespace llvm; - -/// Reads a module from a file. On error, messages are written to stderr -/// and null is returned. -static std::unique_ptr<Module> readModule(LLVMContext &Context, - StringRef Name) { - SMDiagnostic Diag; - std::unique_ptr<Module> M = parseIRFile(Name, Diag, Context); - if (!M) - Diag.print("llvm-diff", errs()); - return M; -} - -static void diffGlobal(DifferenceEngine &Engine, Module &L, Module &R, - StringRef Name) { - // Drop leading sigils from the global name. - if (Name.startswith("@")) Name = Name.substr(1); - - Function *LFn = L.getFunction(Name); - Function *RFn = R.getFunction(Name); - if (LFn && RFn) - Engine.diff(LFn, RFn); - else if (!LFn && !RFn) - errs() << "No function named @" << Name << " in either module\n"; - else if (!LFn) - errs() << "No function named @" << Name << " in left module\n"; - else - errs() << "No function named @" << Name << " in right module\n"; -} - -cl::OptionCategory DiffCategory("Diff Options"); - -static cl::opt<std::string> LeftFilename(cl::Positional, - cl::desc("<first file>"), cl::Required, - cl::cat(DiffCategory)); -static cl::opt<std::string> RightFilename(cl::Positional, - cl::desc("<second file>"), - cl::Required, cl::cat(DiffCategory)); -static cl::list<std::string> GlobalsToCompare(cl::Positional, - cl::desc("<globals to compare>"), - cl::cat(DiffCategory)); - -int main(int argc, char **argv) { - cl::HideUnrelatedOptions({&DiffCategory, &getColorCategory()}); - cl::ParseCommandLineOptions(argc, argv); - - LLVMContext Context; - - // Load both modules. Die if that fails. - std::unique_ptr<Module> LModule = readModule(Context, LeftFilename); - std::unique_ptr<Module> RModule = readModule(Context, RightFilename); - if (!LModule || !RModule) return 1; - - DiffConsumer Consumer; - DifferenceEngine Engine(Consumer); - - // If any global names were given, just diff those. - if (!GlobalsToCompare.empty()) { - for (unsigned I = 0, E = GlobalsToCompare.size(); I != E; ++I) - diffGlobal(Engine, *LModule, *RModule, GlobalsToCompare[I]); - - // Otherwise, diff everything in the module. - } else { - Engine.diff(LModule.get(), RModule.get()); - } - - return Consumer.hadDifferences(); -} |