-
Notifications
You must be signed in to change notification settings - Fork 13.5k
ForceFunctionAttrs: Use reportFatalUsageError #139473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ForceFunctionAttrs: Use reportFatalUsageError #139473
Conversation
@llvm/pr-subscribers-llvm-transforms Author: Matt Arsenault (arsenm) ChangesAlso add a missing test for the failure. Full diff: https://github.com/llvm/llvm-project/pull/139473.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp b/llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
index 9cf4e448c9b6f..5b4d3b7c1be7e 100644
--- a/llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
@@ -92,7 +92,7 @@ PreservedAnalyses ForceFunctionAttrsPass::run(Module &M,
if (!CSVFilePath.empty()) {
auto BufferOrError = MemoryBuffer::getFileOrSTDIN(CSVFilePath);
if (!BufferOrError)
- report_fatal_error("Cannot open CSV file.");
+ reportFatalUsageError("cannot open CSV file");
StringRef Buffer = BufferOrError.get()->getBuffer();
auto MemoryBuffer = MemoryBuffer::getMemBuffer(Buffer);
line_iterator It(*MemoryBuffer);
diff --git a/llvm/test/Transforms/ForcedFunctionAttrs/open-file-error.ll b/llvm/test/Transforms/ForcedFunctionAttrs/open-file-error.ll
new file mode 100644
index 0000000000000..2eded57651616
--- /dev/null
+++ b/llvm/test/Transforms/ForcedFunctionAttrs/open-file-error.ll
@@ -0,0 +1,6 @@
+; RUN: not opt -disable-output -passes='forceattrs' -forceattrs-csv-path="%S/CannotOpenFile.csv" %s 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: cannot open CSV file
+define void @first_function() {
+ ret void
+}
|
Report error in context with the error code. Also add a missing test for the failure.
df88f43
to
6051017
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
if (!BufferOrError) { | ||
std::error_code EC = BufferOrError.getError(); | ||
M.getContext().emitError("cannot open CSV file: " + EC.message()); | ||
return PreservedAnalyses::all(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole flag seems a bit unusual to me, would it make more sense to just continue w/o the file if it doesn't exist after printing an error?
Also add a missing test for the failure.