[clang] [llvm] Delegate __builtin_setjmp SP and FP save to the backend on all targets (PR #186843)
Sean Fertile via cfe-commits
cfe-commits at lists.llvm.org
Wed May 6 10:33:08 PDT 2026
================
@@ -0,0 +1,23 @@
+; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -verify-machineinstrs | FileCheck %s
+
+; Verify that @llvm.eh.sjlj.setjmp stores the special registers
+; (FP, IP, SP, TOC, BP) into the buffer.
+
+ at buf = internal global [5 x ptr] zeroinitializer, align 8
+
+declare i32 @llvm.eh.sjlj.setjmp(ptr) nounwind
+
+define i32 @setjmp_test() nounwind "frame-pointer"="all" {
+ %r = call i32 @llvm.eh.sjlj.setjmp(ptr @buf)
+ ret i32 %r
+}
+
+; CHECK-LABEL: setjmp_test:
+; CHECK: addis [[SCRATCH:[0-9]+]], 2, buf at toc@ha
+; CHECK: addi [[BUFADDR:[0-9]+]], [[SCRATCH]], buf at toc@l
+; CHECK-DAG: std 31, 0([[BUFADDR]])
+; CHECK-DAG: std 1, 16([[BUFADDR]])
+; CHECK-DAG: std 2, 24([[BUFADDR]])
+; CHECK-DAG: std {{[^,]+}}, 32([[BUFADDR]])
----------------
mandlebug wrote:
```suggestion
; CHECK-DAG: std **BASE POINTER**, 32([[BUFADDR]])
```
This is what I pointed out above as a potential bug. I've got a [PR](https://github.com/llvm/llvm-project/pull/195735) posted to fix it. Once this lands I'll rebase to pick up your changes and I think its more informative to explicitly show the bug in the test output.
https://github.com/llvm/llvm-project/pull/186843
More information about the cfe-commits
mailing list