llvm-reduce: Fix crashing on file opening error for mir path

This commit is contained in:
Matt Arsenault
2022-04-22 17:40:25 -04:00
committed by Matt Arsenault
parent 7c2db66632
commit e39e9d339c
2 changed files with 9 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
# REQUIRES: amdgpu-registered-target
# RUN: not llvm-reduce -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg %s --test-arg --input-file does-not-exist.mir 2>&1 | FileCheck -check-prefix=ERR %s
# ERR: {{.*}}llvm-reduce{{.*}}: No such file or directory

View File

@@ -300,6 +300,11 @@ parseReducerWorkItem(const char *ToolName, StringRef Filename,
if (IsMIR) {
auto FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename, /*IsText=*/true);
if (std::error_code EC = FileOrErr.getError()) {
WithColor::error(errs(), ToolName) << EC.message() << '\n';
return nullptr;
}
std::unique_ptr<MIRParser> MParser =
createMIRParser(std::move(FileOrErr.get()), Ctxt);