44 lines · cpp
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-exception7//8//===----------------------------------------------------------------------===//9 10// REQUIRES: target={{riscv64-.+}}11 12#undef NDEBUG13#include <assert.h>14#include <libunwind.h>15 16#ifdef __riscv_vector17__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);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;31 asm volatile("" : "=vr"(v)); // Dummy inline asm to def v.32 stepper(); // def-use of v has cross the function, so that33 // will triger spill/reload to/from the stack.34 asm volatile("" ::"vr"(v)); // Dummy inline asm to use v.35}36 37int main(int, char **) {38 foo();39 return 0;40}41#else42int main(int, char **) { return 0; }43#endif44