Skip to content

Commit ad50d49

Browse files
committed
Address more feedback
1 parent 2462ceb commit ad50d49

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

mlir/include/mlir/Target/SPIRV/Serialization.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ struct SerializationOptions {
3838
/// or an absolute path followed by the prefix. For example:
3939
///
4040
/// * "foo" - Create files with a `foo` prefix in the current working
41-
/// directory. For example: `foo0`, `foo1` ... `fooN`.
41+
/// directory. For example: `fooXYZ123`, `fooABC456` ... `fooXXXXXX`.
42+
/// The last 6 characters will be a unique combination as
43+
/// generated by `llvm::sys::fs::createUniqueFile`.
4244
///
4345
/// * "my/dir/foo" - Create files in `my/dir` with a `foo` prefix. The
44-
/// `my/dir` need to exists. For example: `foo0`, `foo1` ... `fooN`
45-
/// will be created and stored in `/my/dir`.
46+
/// `my/dir` need to exists. For example: `fooXYZ123`, `fooABC456` ...
47+
/// `fooXXXXXX` will be created and stored in `/my/dir`. Filenames
48+
/// follow the same pattern as above.
4649
///
4750
/// * "/home/user/my/dir" - Same as above but using an absolute path.
4851
std::string validationFilePrefix = "";

mlir/lib/Target/SPIRV/TranslateRegistration.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,19 @@ serializeModule(spirv::ModuleOp moduleOp, raw_ostream &output,
9898
llvm::StringRef parentDir =
9999
llvm::sys::path::parent_path(options.validationFilePrefix);
100100
if (!llvm::sys::fs::is_directory(parentDir)) {
101-
llvm::errs() << "validation prefix directory does not exist\n";
101+
moduleOp.emitError("validation prefix directory does not exist\n");
102102
return failure();
103103
}
104104
}
105105

106106
SmallString<128> filename;
107-
int fd;
107+
int fd = 0;
108108

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

mlir/test/Target/SPIRV/mlir-translate.mlir

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
// COM: Check that `--spirv-save-validation-files-with-prefix` generates
2-
// COM: a correct number of files.
1+
// Check that `--spirv-save-validation-files-with-prefix` generates
2+
// a correct number of files.
33

44
// REQUIRES: shell
55
// RUN: rm -rf %t
6-
// RUN: mkdir %t
7-
// RUN: mlir-translate --serialize-spirv --no-implicit-module --split-input-file --spirv-save-validation-files-with-prefix=%t/foo %s
8-
// RUN: ls %t | wc -l | FileCheck %s
6+
// 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
97
// RUN: rm -rf %t
108

119
// CHECK: 4

0 commit comments

Comments
 (0)