[NFC][Py Reformat] Reformat python files in llvm
[llvm-project.git] / libunwind / test / unwind_scalable_vectors.pass.cpp
bloba5c5947c870fd1579474dba64e005066995ac267
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 // REQUIRES: linux && target={{riscv64-.+}}
12 #undef NDEBUG
13 #include <assert.h>
14 #include <libunwind.h>
16 #ifdef __riscv_vector
17 __attribute__((noinline)) extern "C" void stepper() {
18 unw_cursor_t cursor;
19 unw_context_t uc;
20 unw_getcontext(&uc);
21 unw_init_local(&cursor, &uc);
22 // Stepping into foo() should succeed.
23 assert(unw_step(&cursor) > 0);
24 // Stepping past foo() should succeed, too.
25 assert(unw_step(&cursor) > 0);
28 // Check correct unwinding of frame with VLENB-sized objects (vector registers).
29 __attribute__((noinline)) static void foo() {
30 __rvv_int32m1_t v;
31 asm volatile("" : "=vr"(v)); // Dummy inline asm to def v.
32 stepper(); // def-use of v has cross the function, so that
33 // will triger spill/reload to/from the stack.
34 asm volatile("" ::"vr"(v)); // Dummy inline asm to use v.
37 int main() { foo(); }
38 #else
39 int main() { return 0; }
40 #endif