[clang] [llvm] [RISCV] Avoid fatal error for SiFive CLIC preemptible frame pointers (PR #217949)
Zeyi Xu via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 22 01:18:28 PDT 2026
https://github.com/zeyi2 updated https://github.com/llvm/llvm-project/pull/217949
>From c7dd6d4501d184be16785d6e0087cef41ef60944 Mon Sep 17 00:00:00 2001
From: Zeyi Xu <mitchell.xu2 at gmail.com>
Date: Fri, 21 Aug 2026 23:28:35 +0800
Subject: [PATCH 1/2] [RISCV] Avoid a fatal error for SiFive CLIC preemptible
frame pointers
---
clang/docs/ReleaseNotes.md | 3 +++
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 5 +++--
llvm/test/CodeGen/RISCV/sifive-interrupt-attr-err.ll | 4 ++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 8c9467ca7b742..6e33c8c4891fb 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -595,6 +595,9 @@ features cannot lower the translation-unit ABI level;
- Added a new warning when the same interrupt type is specified more than
once in a RISC-V `interrupt` attribute.
+- SiFive CLIC preemptible interrupt handlers now diagnose unsupported frame
+ pointers instead of producing a backend fatal error.
+
- Added `-march=native` for better compatibility with ARM, AArch64, and X86. This
option will be treated like `-mcpu=native` if `-mcpu` is not present. If
`-mcpu` is present, the ISA will be selected from the host CPU and the tune
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 1db51b19fde2d..f3f10224378c5 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -26239,8 +26239,9 @@ SDValue RISCVTargetLowering::LowerFormalArguments(
reportFatalUsageError("'rnmi' interrupt kind requires Srnmi extension");
const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
if (Kind.starts_with("SiFive-CLIC-preemptible") && TFI->hasFP(MF))
- reportFatalUsageError("'SiFive-CLIC-preemptible' interrupt kinds cannot "
- "have a frame pointer");
+ Func.getContext().diagnose(DiagnosticInfoUnsupported{
+ Func, "'SiFive-CLIC-preemptible' interrupt kinds cannot have a frame "
+ "pointer; consider compiling with '-fomit-frame-pointer'"});
}
EVT PtrVT = getPointerTy(DAG.getDataLayout());
diff --git a/llvm/test/CodeGen/RISCV/sifive-interrupt-attr-err.ll b/llvm/test/CodeGen/RISCV/sifive-interrupt-attr-err.ll
index ccc11b74f78e7..9e06762f4e71d 100644
--- a/llvm/test/CodeGen/RISCV/sifive-interrupt-attr-err.ll
+++ b/llvm/test/CodeGen/RISCV/sifive-interrupt-attr-err.ll
@@ -3,9 +3,9 @@
; RUN: not llc -mtriple riscv64-unknown-elf -mattr=+experimental-xsfmclic -o - %s 2>&1 \
; RUN: | FileCheck %s
-;; Test that these report fatal errors.
+;; Test that these report regular errors.
-; CHECK: LLVM ERROR: 'SiFive-CLIC-preemptible' interrupt kinds cannot have a frame pointer
+; CHECK: error: <unknown>:0:0: in function preemptible void (): 'SiFive-CLIC-preemptible' interrupt kinds cannot have a frame pointer; consider compiling with '-fomit-frame-pointer'
define void @preemptible() "interrupt"="SiFive-CLIC-preemptible" "frame-pointer"="all" {
ret void
>From f2849700214e4d2440493cc1dd80f1650428228b Mon Sep 17 00:00:00 2001
From: Zeyi Xu <mitchell.xu2 at gmail.com>
Date: Sat, 22 Aug 2026 16:18:11 +0800
Subject: [PATCH 2/2] Address feddback
---
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 5 +++--
llvm/test/CodeGen/RISCV/sifive-interrupt-attr-err.ll | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index f3f10224378c5..5b59d63cf3e19 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -26240,8 +26240,9 @@ SDValue RISCVTargetLowering::LowerFormalArguments(
const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
if (Kind.starts_with("SiFive-CLIC-preemptible") && TFI->hasFP(MF))
Func.getContext().diagnose(DiagnosticInfoUnsupported{
- Func, "'SiFive-CLIC-preemptible' interrupt kinds cannot have a frame "
- "pointer; consider compiling with '-fomit-frame-pointer'"});
+ Func,
+ "'SiFive-CLIC-preemptible' interrupt functions cannot have a frame "
+ "pointer"});
}
EVT PtrVT = getPointerTy(DAG.getDataLayout());
diff --git a/llvm/test/CodeGen/RISCV/sifive-interrupt-attr-err.ll b/llvm/test/CodeGen/RISCV/sifive-interrupt-attr-err.ll
index 9e06762f4e71d..f0e1f16cf6e54 100644
--- a/llvm/test/CodeGen/RISCV/sifive-interrupt-attr-err.ll
+++ b/llvm/test/CodeGen/RISCV/sifive-interrupt-attr-err.ll
@@ -5,7 +5,7 @@
;; Test that these report regular errors.
-; CHECK: error: <unknown>:0:0: in function preemptible void (): 'SiFive-CLIC-preemptible' interrupt kinds cannot have a frame pointer; consider compiling with '-fomit-frame-pointer'
+; CHECK: error: <unknown>:0:0: in function preemptible void (): 'SiFive-CLIC-preemptible' interrupt functions cannot have a frame pointer
define void @preemptible() "interrupt"="SiFive-CLIC-preemptible" "frame-pointer"="all" {
ret void
More information about the llvm-commits
mailing list