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 stepper()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); 26 } 27 28 // Check correct unwinding of frame with VLENB-sized objects (vector registers). foo()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. 35 } 36 main()37int main() { foo(); } 38 #else main()39int main() { return 0; } 40 #endif 41