llvm-project
40 строк · 1.3 Кб
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//===----------------------------------------------------------------------===//
9
10// REQUIRES: linux && target={{riscv64-.+}}
11
12#undef NDEBUG
13#include <assert.h>
14#include <libunwind.h>
15
16#ifdef __riscv_vector
17__attribute__((noinline)) extern "C" void stepper() {
18unw_cursor_t cursor;
19unw_context_t uc;
20unw_getcontext(&uc);
21unw_init_local(&cursor, &uc);
22// Stepping into foo() should succeed.
23assert(unw_step(&cursor) > 0);
24// Stepping past foo() should succeed, too.
25assert(unw_step(&cursor) > 0);
26}
27
28// Check correct unwinding of frame with VLENB-sized objects (vector registers).
29__attribute__((noinline)) static void foo() {
30__rvv_int32m1_t v;
31asm volatile("" : "=vr"(v)); // Dummy inline asm to def v.
32stepper(); // def-use of v has cross the function, so that
33// will triger spill/reload to/from the stack.
34asm volatile("" ::"vr"(v)); // Dummy inline asm to use v.
35}
36
37int main() { foo(); }
38#else
39int main() { return 0; }
40#endif
41