[llvm] 478d093 - [RISCV][GISel] Reverse the operands the buildStore created in legalizeVAStart. (#73989)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 8 10:45:57 PST 2023
Author: Craig Topper
Date: 2023-12-08T10:45:53-08:00
New Revision: 478d093e1b58e1054f549aec4be5d27e26bdd062
URL: https://github.com/llvm/llvm-project/commit/478d093e1b58e1054f549aec4be5d27e26bdd062
DIFF: https://github.com/llvm/llvm-project/commit/478d093e1b58e1054f549aec4be5d27e26bdd062.diff
LOG: [RISCV][GISel] Reverse the operands the buildStore created in legalizeVAStart. (#73989)
We need to store the frame index to the location pointed to by the
VASTART, not the other way around.
Added:
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-vastart-rv32.mir
llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-vastart-rv64.mir
Modified:
llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
index f47db58e09372..8f03a7ac41d37 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp
@@ -406,7 +406,7 @@ bool RISCVLegalizerInfo::legalizeVAStart(MachineInstr &MI,
LLT AddrTy = MIRBuilder.getMRI()->getType(MI.getOperand(0).getReg());
auto FINAddr = MIRBuilder.buildFrameIndex(AddrTy, FI);
assert(MI.hasOneMemOperand());
- MIRBuilder.buildStore(MI.getOperand(0).getReg(), FINAddr,
+ MIRBuilder.buildStore(FINAddr, MI.getOperand(0).getReg(),
*MI.memoperands()[0]);
MI.eraseFromParent();
return true;
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-vastart-rv32.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-vastart-rv32.mir
new file mode 100644
index 0000000000000..289a51476c6c9
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-vastart-rv32.mir
@@ -0,0 +1,29 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=riscv32 -run-pass=legalizer %s -o - | FileCheck --check-prefix=RV32 %s
+
+---
+name: test_va_start
+tracksRegLiveness: true
+fixedStack:
+ - { id: 0, size: 4, alignment: 16, isImmutable: true }
+stack:
+ - { id: 0, size: 4, alignment: 4 }
+machineFunctionInfo:
+ varArgsFrameIndex: -1
+ varArgsSaveSize: 0
+body: |
+ bb.1:
+ liveins: $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17
+
+ ; RV32-LABEL: name: test_va_start
+ ; RV32: liveins: $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17
+ ; RV32-NEXT: {{ $}}
+ ; RV32-NEXT: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0
+ ; RV32-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; RV32-NEXT: G_STORE [[FRAME_INDEX]](p0), [[FRAME_INDEX1]](p0) :: (store (s32))
+ ; RV32-NEXT: PseudoRET
+ %8:_(p0) = G_FRAME_INDEX %stack.0
+ G_VASTART %8(p0) :: (store (s32))
+ PseudoRET
+
+...
diff --git a/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-vastart-rv64.mir b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-vastart-rv64.mir
new file mode 100644
index 0000000000000..b75310a1a16cc
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/GlobalISel/legalizer/legalize-vastart-rv64.mir
@@ -0,0 +1,29 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=riscv64 -run-pass=legalizer %s -o - | FileCheck --check-prefix=RV64 %s
+
+---
+name: test_va_start
+tracksRegLiveness: true
+fixedStack:
+ - { id: 0, size: 8, alignment: 16, isImmutable: true }
+stack:
+ - { id: 0, size: 8, alignment: 8 }
+machineFunctionInfo:
+ varArgsFrameIndex: -1
+ varArgsSaveSize: 0
+body: |
+ bb.1:
+ liveins: $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17
+
+ ; RV64-LABEL: name: test_va_start
+ ; RV64: liveins: $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17
+ ; RV64-NEXT: {{ $}}
+ ; RV64-NEXT: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0
+ ; RV64-NEXT: [[FRAME_INDEX1:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0
+ ; RV64-NEXT: G_STORE [[FRAME_INDEX]](p0), [[FRAME_INDEX1]](p0) :: (store (s64))
+ ; RV64-NEXT: PseudoRET
+ %8:_(p0) = G_FRAME_INDEX %stack.0
+ G_VASTART %8(p0) :: (store (s64))
+ PseudoRET
+
+...
More information about the llvm-commits
mailing list