mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 05:56:05 +00:00

Fix #60472 The testcase is writen in all inline asm but it seems not well maintained for the CFI directive, of cause we can fix that, but this patch also contain another issue is it use s0 and s1 without store/restore. This patch proposed another way to testing that, use inline asm to generate dummy def and use, so compiler will generate store/restore for the vector register, and then generate the CFI directives. Also check __riscv_vector as the testcase guard, because the testcase will read vlenb which is only available when V or zve* extensions is present. Reviewed By: MaskRay, asb, #libunwind Differential Revision: https://reviews.llvm.org/D145225
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// -*- C++ -*-
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// REQUIRES: linux && target={{riscv64-.+}}
|
|
|
|
#undef NDEBUG
|
|
#include <assert.h>
|
|
#include <libunwind.h>
|
|
|
|
#ifdef __riscv_vector
|
|
__attribute__((noinline)) extern "C" void stepper() {
|
|
unw_cursor_t cursor;
|
|
unw_context_t uc;
|
|
unw_getcontext(&uc);
|
|
unw_init_local(&cursor, &uc);
|
|
// Stepping into foo() should succeed.
|
|
assert(unw_step(&cursor) > 0);
|
|
// Stepping past foo() should succeed, too.
|
|
assert(unw_step(&cursor) > 0);
|
|
}
|
|
|
|
// Check correct unwinding of frame with VLENB-sized objects (vector registers).
|
|
__attribute__((noinline)) static void foo() {
|
|
__rvv_int32m1_t v;
|
|
asm volatile("" : "=vr"(v)); // Dummy inline asm to def v.
|
|
stepper(); // def-use of v has cross the function, so that
|
|
// will triger spill/reload to/from the stack.
|
|
asm volatile("" ::"vr"(v)); // Dummy inline asm to use v.
|
|
}
|
|
|
|
int main() { foo(); }
|
|
#else
|
|
int main() { return 0; }
|
|
#endif
|