[llvm] ForceFunctionAttrs: Use reportFatalUsageError (PR #139473)
via llvm-commits
llvm-commits at lists.llvm.org
Sun May 11 14:03:27 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
Also add a missing test for the failure.
---
Full diff: https://github.com/llvm/llvm-project/pull/139473.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp (+1-1)
- (added) llvm/test/Transforms/ForcedFunctionAttrs/open-file-error.ll (+6)
``````````diff
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
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/139473
More information about the llvm-commits
mailing list