Skip to content

Conversation

@mgudim
Copy link
Contributor

@mgudim mgudim commented Oct 21, 2025

Technically, it is possible that the a callee-saved register is saved in different locations. CFIInstrInserter should handle this, but currently it does not.

@llvmbot
Copy link
Member

llvmbot commented Oct 21, 2025

@llvm/pr-subscribers-backend-risc-v

Author: Mikhail Gudim (mgudim)

Changes

Technically, it is possible that the a callee-saved register is saved in different locations. CFIInstrInserter should handle this, but currently it does not.


Full diff: https://github.com/llvm/llvm-project/pull/164479.diff

1 Files Affected:

  • (added) llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir (+35)
diff --git a/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir b/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir
new file mode 100644
index 0000000000000..075536e10bce6
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/cfi-multiple-locations.mir
@@ -0,0 +1,35 @@
+# RUN: llc %s -mtriple=riscv64 \
+# RUN: -run-pass=cfi-instr-inserter \
+# RUN: -riscv-enable-cfi-instr-inserter=true
+# XFAIL: *
+
+# Technically, it is possible that the a callee-saved register is saved in different locations.
+# CFIInstrInserter should handle this, but currently it does not.
+---
+name: multiple_locations
+tracksRegLiveness: true
+body:             |
+  bb.0.entry:
+    liveins: $x10, $x9, $x2
+    BEQ $x10, $x0, %bb.3
+    PseudoBR %bb.2
+
+  bb.1:
+    liveins: $x10, $x9, $x2
+    $x5 = COPY $x9
+    CFI_INSTRUCTION register $x9, $x5
+    $x9 = COPY $x5
+    CFI_INSTRUCTION register $x9, $x9
+    PseudoBR %bb.3
+
+  bb.2:
+    liveins: $x10, $x9, $x2
+    SD $x9, $x2, 0 :: (store (s64))
+    CFI_INSTRUCTION offset $x9, 0
+    $x9  = LD $x2, 0 :: (load (s64))
+    CFI_INSTRUCTION register $x9, $x9
+    PseudoBR %bb.3
+
+  bb.3:
+    PseudoRET
+...

@topperc
Copy link
Collaborator

topperc commented Oct 21, 2025

Please put [RISCV] in the title as is the convention. I have email filters set up on various tags as I'm sure others do.

@mgudim mgudim changed the title Add a test for multiple save locations of a CSR. [RISCV] Add a test for multiple save locations of a CSR. Oct 21, 2025
Technically, it is possible that the a callee-saved register is saved
in different locations. CFIInstrInserter should handle this, but
currently it does not.
@mgudim mgudim force-pushed the test_cfi_multiple_locations branch from 30d10a9 to 4f5d8e0 Compare October 21, 2025 21:10
@lenary
Copy link
Member

lenary commented Oct 31, 2025

Can you not use "CSR" in the title? CSR has a specific RISC-V meaning, as well as not actually differentiating between "caller-saved register" and "callee-saved register".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants