diff options
author | vitalyisaev <vitalyisaev@yandex-team.com> | 2023-06-29 10:00:50 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@yandex-team.com> | 2023-06-29 10:00:50 +0300 |
commit | 6ffe9e53658409f212834330e13564e4952558f6 (patch) | |
tree | 85b1e00183517648b228aafa7c8fb07f5276f419 /contrib/libs/llvm14/tools/llvm-cat | |
parent | 726057070f9c5a91fc10fde0d5024913d10f1ab9 (diff) | |
download | ydb-6ffe9e53658409f212834330e13564e4952558f6.tar.gz |
YQ Connector: support managed ClickHouse
Со стороны dqrun можно обратиться к инстансу коннектора, который работает на streaming стенде, и извлечь данные из облачного CH.
Diffstat (limited to 'contrib/libs/llvm14/tools/llvm-cat')
-rw-r--r-- | contrib/libs/llvm14/tools/llvm-cat/llvm-cat.cpp | 96 | ||||
-rw-r--r-- | contrib/libs/llvm14/tools/llvm-cat/ya.make | 43 |
2 files changed, 139 insertions, 0 deletions
diff --git a/contrib/libs/llvm14/tools/llvm-cat/llvm-cat.cpp b/contrib/libs/llvm14/tools/llvm-cat/llvm-cat.cpp new file mode 100644 index 0000000000..39848e5d33 --- /dev/null +++ b/contrib/libs/llvm14/tools/llvm-cat/llvm-cat.cpp @@ -0,0 +1,96 @@ +//===- llvm-cat.cpp - LLVM module concatenation utility -------------------===// +// +// 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 program is for testing features that rely on multi-module bitcode files. +// It takes a list of input modules and uses them to create a multi-module +// bitcode file. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/SmallVector.h" +#include "llvm/Bitcode/BitcodeReader.h" +#include "llvm/Bitcode/BitcodeWriter.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Module.h" +#include "llvm/IRReader/IRReader.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/SourceMgr.h" +#include "llvm/Support/raw_ostream.h" +#include <algorithm> +#include <memory> +#include <string> +#include <system_error> +#include <vector> + +using namespace llvm; + +cl::OptionCategory CatCategory("llvm-cat Options"); + +static cl::opt<bool> + BinaryCat("b", cl::desc("Whether to perform binary concatenation"), + cl::cat(CatCategory)); + +static cl::opt<std::string> OutputFilename("o", cl::Required, + cl::desc("Output filename"), + cl::value_desc("filename"), + cl::cat(CatCategory)); + +static cl::list<std::string> InputFilenames(cl::Positional, cl::ZeroOrMore, + cl::desc("<input files>"), + cl::cat(CatCategory)); + +int main(int argc, char **argv) { + cl::HideUnrelatedOptions(CatCategory); + cl::ParseCommandLineOptions(argc, argv, "Module concatenation"); + + ExitOnError ExitOnErr("llvm-cat: "); + LLVMContext Context; + + SmallVector<char, 0> Buffer; + BitcodeWriter Writer(Buffer); + if (BinaryCat) { + for (const auto &InputFilename : InputFilenames) { + std::unique_ptr<MemoryBuffer> MB = ExitOnErr( + errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename))); + std::vector<BitcodeModule> Mods = ExitOnErr(getBitcodeModuleList(*MB)); + for (auto &BitcodeMod : Mods) { + llvm::append_range(Buffer, BitcodeMod.getBuffer()); + Writer.copyStrtab(BitcodeMod.getStrtab()); + } + } + } else { + // The string table does not own strings added to it, some of which are + // owned by the modules; keep them alive until we write the string table. + std::vector<std::unique_ptr<Module>> OwnedMods; + for (const auto &InputFilename : InputFilenames) { + SMDiagnostic Err; + std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context); + if (!M) { + Err.print(argv[0], errs()); + return 1; + } + Writer.writeModule(*M); + OwnedMods.push_back(std::move(M)); + } + Writer.writeStrtab(); + } + + std::error_code EC; + raw_fd_ostream OS(OutputFilename, EC, sys::fs::OpenFlags::OF_None); + if (EC) { + errs() << argv[0] << ": cannot open " << OutputFilename << " for writing: " + << EC.message(); + return 1; + } + + OS.write(Buffer.data(), Buffer.size()); + return 0; +} diff --git a/contrib/libs/llvm14/tools/llvm-cat/ya.make b/contrib/libs/llvm14/tools/llvm-cat/ya.make new file mode 100644 index 0000000000..d39a54c54d --- /dev/null +++ b/contrib/libs/llvm14/tools/llvm-cat/ya.make @@ -0,0 +1,43 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +LICENSE(Apache-2.0 WITH LLVM-exception) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +PEERDIR( + contrib/libs/llvm14 + contrib/libs/llvm14/include + contrib/libs/llvm14/lib/Analysis + contrib/libs/llvm14/lib/AsmParser + contrib/libs/llvm14/lib/BinaryFormat + contrib/libs/llvm14/lib/Bitcode/Reader + contrib/libs/llvm14/lib/Bitcode/Writer + contrib/libs/llvm14/lib/Bitstream/Reader + contrib/libs/llvm14/lib/DebugInfo/DWARF + contrib/libs/llvm14/lib/Demangle + contrib/libs/llvm14/lib/IR + contrib/libs/llvm14/lib/IRReader + contrib/libs/llvm14/lib/MC + contrib/libs/llvm14/lib/MC/MCParser + contrib/libs/llvm14/lib/Object + contrib/libs/llvm14/lib/ProfileData + contrib/libs/llvm14/lib/Remarks + contrib/libs/llvm14/lib/Support + contrib/libs/llvm14/lib/TextAPI +) + +ADDINCL( + contrib/libs/llvm14/tools/llvm-cat +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + llvm-cat.cpp +) + +END() |