Skip to content

Commit 7fee589

Browse files
committed
support-stdin-input-llvm-ir2vec
1 parent 01c6091 commit 7fee589

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

llvm/tools/llvm-ir2vec/llvm-ir2vec.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ namespace ir2vec {
4848

4949
static cl::OptionCategory IR2VecToolCategory("IR2Vec Tool Options");
5050

51-
static cl::opt<std::string> InputFilename(cl::Positional,
52-
cl::desc("<input bitcode file>"),
53-
cl::Required,
54-
cl::cat(IR2VecToolCategory));
51+
static cl::opt<std::string>
52+
InputFilename(cl::Positional,
53+
cl::desc("<input bitcode file or '-' for stdin>"),
54+
cl::init("-"), cl::cat(IR2VecToolCategory));
5555

5656
static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
5757
cl::value_desc("filename"),
@@ -287,10 +287,14 @@ int main(int argc, char **argv) {
287287
if (Mode == TripletMode && Level.getNumOccurrences() > 0)
288288
errs() << "Warning: --level option is ignored in triplet mode\n";
289289

290-
// Parse the input LLVM IR file
290+
// Parse the input LLVM IR file or stdin
291291
SMDiagnostic Err;
292292
LLVMContext Context;
293-
std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);
293+
std::unique_ptr<Module> M;
294+
295+
// Read from file or stdin
296+
M = parseIRFile(InputFilename, Err, Context);
297+
294298
if (!M) {
295299
Err.print(argv[0], errs());
296300
return 1;

0 commit comments

Comments
 (0)