[llvm-branch-commits] [llvm] [IR2Vec][llvm-ir2vec] Add support for reading from stdin (PR #149213)
S. VenkataKeerthy via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jul 17 11:04:57 PDT 2025
https://github.com/svkeerthy updated https://github.com/llvm/llvm-project/pull/149213
>From 090355226c63ebe3a010061d2dab545f217edf5c Mon Sep 17 00:00:00 2001
From: svkeerthy <venkatakeerthy at google.com>
Date: Wed, 16 Jul 2025 22:01:47 +0000
Subject: [PATCH] support-stdin-input-llvm-ir2vec
---
llvm/tools/llvm-ir2vec/llvm-ir2vec.cpp | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/llvm/tools/llvm-ir2vec/llvm-ir2vec.cpp b/llvm/tools/llvm-ir2vec/llvm-ir2vec.cpp
index 4e88282e85c14..e3aa7bd1b3b1e 100644
--- a/llvm/tools/llvm-ir2vec/llvm-ir2vec.cpp
+++ b/llvm/tools/llvm-ir2vec/llvm-ir2vec.cpp
@@ -48,10 +48,10 @@ namespace ir2vec {
static cl::OptionCategory IR2VecToolCategory("IR2Vec Tool Options");
-static cl::opt<std::string> InputFilename(cl::Positional,
- cl::desc("<input bitcode file>"),
- cl::Required,
- cl::cat(IR2VecToolCategory));
+static cl::opt<std::string>
+ InputFilename(cl::Positional,
+ cl::desc("<input bitcode file or '-' for stdin>"),
+ cl::init("-"), cl::cat(IR2VecToolCategory));
static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
cl::value_desc("filename"),
@@ -287,10 +287,14 @@ int main(int argc, char **argv) {
if (Mode == TripletMode && Level.getNumOccurrences() > 0)
errs() << "Warning: --level option is ignored in triplet mode\n";
- // Parse the input LLVM IR file
+ // Parse the input LLVM IR file or stdin
SMDiagnostic Err;
LLVMContext Context;
- std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);
+ std::unique_ptr<Module> M;
+
+ // Read from file or stdin
+ M = parseIRFile(InputFilename, Err, Context);
+
if (!M) {
Err.print(argv[0], errs());
return 1;
More information about the llvm-branch-commits
mailing list