Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions mlir/include/mlir/Target/SPIRV/Serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ struct SerializationOptions {
/// or an absolute path followed by the prefix. For example:
///
/// * "foo" - Create files with a `foo` prefix in the current working
/// directory. For example: `foo0`, `foo1` ... `fooN`.
/// directory. For example: `fooXYZ123`, `fooABC456` ... `fooXXXXXX`.
/// The last 6 characters will be a unique combination as
/// generated by `llvm::sys::fs::createUniqueFile`.
///
/// * "my/dir/foo" - Create files in `my/dir` with a `foo` prefix. The
/// `my/dir` need to exists. For example: `foo0`, `foo1` ... `fooN`
/// will be created and stored in `/my/dir`.
/// `my/dir` need to exists. For example: `fooXYZ123`, `fooABC456` ...
/// `fooXXXXXX` will be created and stored in `/my/dir`. Filenames
/// follow the same pattern as above.
///
/// * "/home/user/my/dir" - Same as above but using an absolute path.
std::string validationFilePrefix = "";
Expand Down
8 changes: 4 additions & 4 deletions mlir/lib/Target/SPIRV/TranslateRegistration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ serializeModule(spirv::ModuleOp moduleOp, raw_ostream &output,
llvm::StringRef parentDir =
llvm::sys::path::parent_path(options.validationFilePrefix);
if (!llvm::sys::fs::is_directory(parentDir)) {
llvm::errs() << "validation prefix directory does not exist\n";
moduleOp.emitError("validation prefix directory does not exist\n");
return failure();
}
}

SmallString<128> filename;
int fd;
int fd = 0;

std::error_code errorCode = llvm::sys::fs::createUniqueFile(
options.validationFilePrefix + "%%%%%%", fd, filename);
if (errorCode) {
llvm::errs() << "error creating validation output file: "
<< errorCode.message() << "\n";
moduleOp.emitError("error creating validation output file: ")
<< errorCode.message() << "\n";
return failure();
}

Expand Down
8 changes: 3 additions & 5 deletions mlir/test/Target/SPIRV/mlir-translate.mlir
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// COM: Check that `--spirv-save-validation-files-with-prefix` generates
// COM: a correct number of files.
// Check that `--spirv-save-validation-files-with-prefix` generates
// a correct number of files.

// REQUIRES: shell
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: mlir-translate --serialize-spirv --no-implicit-module --split-input-file --spirv-save-validation-files-with-prefix=%t/foo %s
// RUN: ls %t | wc -l | FileCheck %s
// RUN: mkdir %t && mlir-translate --serialize-spirv --no-implicit-module --split-input-file --spirv-save-validation-files-with-prefix=%t/foo %s && ls %t | wc -l | FileCheck %s
// RUN: rm -rf %t

// CHECK: 4
Expand Down
Loading