[llvm] ForceFunctionAttrs: Use reportFatalUsageError (PR #139473)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun May 11 14:02:53 PDT 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/139473
Also add a missing test for the failure.
>From df88f439d195612a799cc1f318ee247940e56727 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Sun, 11 May 2025 22:55:57 +0200
Subject: [PATCH] ForceFunctionAttrs: Use reportFatalUsageError
Also add a missing test for the failure.
---
llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp | 2 +-
llvm/test/Transforms/ForcedFunctionAttrs/open-file-error.ll | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/Transforms/ForcedFunctionAttrs/open-file-error.ll
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
+}
More information about the llvm-commits
mailing list