public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/110665] New: RISC-V do not preserve vector registers in interrupt handler
@ 2023-07-14 13:11 lehua.ding at rivai dot ai
  2023-07-14 13:15 ` [Bug target/110665] " lehua.ding at rivai dot ai
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: lehua.ding at rivai dot ai @ 2023-07-14 13:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110665

            Bug ID: 110665
           Summary: RISC-V do not preserve vector registers in interrupt
                    handler
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lehua.ding at rivai dot ai
  Target Milestone: ---

When an interrupt handler uses vector registers or calls other functions, the
handler needs to preserve the content in vector registers like GP or FP
registers. Currently, the GCC fully ignores the existence of vector registers
for this case even using -march=rv64gcv option.

Issue on Compiler Explorer: https://godbolt.org/z/nTGzr4o5P

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/110665] RISC-V do not preserve vector registers in interrupt handler
  2023-07-14 13:11 [Bug target/110665] New: RISC-V do not preserve vector registers in interrupt handler lehua.ding at rivai dot ai
@ 2023-07-14 13:15 ` lehua.ding at rivai dot ai
  2023-07-14 13:28 ` lehua.ding at rivai dot ai
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: lehua.ding at rivai dot ai @ 2023-07-14 13:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110665

--- Comment #1 from Lehua Ding <lehua.ding at rivai dot ai> ---
If it's a problem, I'm willing to fix it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/110665] RISC-V do not preserve vector registers in interrupt handler
  2023-07-14 13:11 [Bug target/110665] New: RISC-V do not preserve vector registers in interrupt handler lehua.ding at rivai dot ai
  2023-07-14 13:15 ` [Bug target/110665] " lehua.ding at rivai dot ai
@ 2023-07-14 13:28 ` lehua.ding at rivai dot ai
  2023-09-15  2:33 ` lehua.ding at rivai dot ai
  2023-10-25  6:21 ` lehua.ding at rivai dot ai
  3 siblings, 0 replies; 5+ messages in thread
From: lehua.ding at rivai dot ai @ 2023-07-14 13:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110665

--- Comment #2 from Lehua Ding <lehua.ding at rivai dot ai> ---
I just found the relevant specification and the specification seems to require
that the vector registers used be saved.

> The interrupt attribute specifies that a function is an interrupt handler.
> The compiler will save/restore all used registers in the prologue/epilogue
> regardless of the ABI, all used registers including floating point
> register/vector register if F extension/vector extension is enabled.

From
https://github.com/riscv-non-isa/riscv-c-api-doc/blob/master/riscv-c-api.md#__attribute__interrupt-__attribute__interruptuser-__attribute__interruptsupervisor-__attribute__interruptmachine

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/110665] RISC-V do not preserve vector registers in interrupt handler
  2023-07-14 13:11 [Bug target/110665] New: RISC-V do not preserve vector registers in interrupt handler lehua.ding at rivai dot ai
  2023-07-14 13:15 ` [Bug target/110665] " lehua.ding at rivai dot ai
  2023-07-14 13:28 ` lehua.ding at rivai dot ai
@ 2023-09-15  2:33 ` lehua.ding at rivai dot ai
  2023-10-25  6:21 ` lehua.ding at rivai dot ai
  3 siblings, 0 replies; 5+ messages in thread
From: lehua.ding at rivai dot ai @ 2023-09-15  2:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110665

--- Comment #3 from Lehua Ding <lehua.ding at rivai dot ai> ---
Fixed by the commit
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=fdd59c0f73e9e681cd5f4d0eee2dd58d60d8dbe1

with compiler option --param=riscv-vector-abi.
Confirmed after support riscv-vector-abi in default.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/110665] RISC-V do not preserve vector registers in interrupt handler
  2023-07-14 13:11 [Bug target/110665] New: RISC-V do not preserve vector registers in interrupt handler lehua.ding at rivai dot ai
                   ` (2 preceding siblings ...)
  2023-09-15  2:33 ` lehua.ding at rivai dot ai
@ 2023-10-25  6:21 ` lehua.ding at rivai dot ai
  3 siblings, 0 replies; 5+ messages in thread
From: lehua.ding at rivai dot ai @ 2023-10-25  6:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110665

Lehua Ding <lehua.ding at rivai dot ai> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Lehua Ding <lehua.ding at rivai dot ai> ---
Fixed on trunk with --param=riscv-vector-abi options

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-25  6:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-14 13:11 [Bug target/110665] New: RISC-V do not preserve vector registers in interrupt handler lehua.ding at rivai dot ai
2023-07-14 13:15 ` [Bug target/110665] " lehua.ding at rivai dot ai
2023-07-14 13:28 ` lehua.ding at rivai dot ai
2023-09-15  2:33 ` lehua.ding at rivai dot ai
2023-10-25  6:21 ` lehua.ding at rivai dot ai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).