Skip to content

Commit ee4b3c6

Browse files
committed
fixup! [RISCV] Xqccmp Code Generation
1 parent a80217e commit ee4b3c6

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

llvm/lib/Target/RISCV/RISCVPushPopOptimizer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "RISCVInstrInfo.h"
1515
#include "RISCVMachineFunctionInfo.h"
16+
#include "llvm/CodeGen/MachineInstr.h"
1617

1718
using namespace llvm;
1819

@@ -72,7 +73,7 @@ static unsigned getPopRetOpcode(unsigned PopOpcode, bool IsReturnZero) {
7273
static MachineBasicBlock::iterator containsPop(MachineBasicBlock &MBB) {
7374
for (MachineBasicBlock::iterator MBBI = MBB.begin(); MBBI != MBB.end();
7475
MBBI = next_nodbg(MBBI, MBB.end()))
75-
if (isPop(MBBI->getOpcode()))
76+
if (MBBI->getFlag(MachineInstr::FrameDestroy) && isPop(MBBI->getOpcode()))
7677
return MBBI;
7778

7879
return MBB.end();
@@ -85,11 +86,11 @@ bool RISCVPushPopOpt::usePopRet(MachineBasicBlock::iterator &MBBI,
8586
// this will detect all ret instruction.
8687
DebugLoc DL = NextI->getDebugLoc();
8788
unsigned Opc = getPopRetOpcode(MBBI->getOpcode(), IsReturnZero);
88-
// unsigned Opc = IsReturnZero ? RISCV::CM_POPRETZ : RISCV::CM_POPRET;
8989
MachineInstrBuilder PopRetBuilder =
9090
BuildMI(*NextI->getParent(), NextI, DL, TII->get(Opc))
9191
.add(MBBI->getOperand(0))
92-
.add(MBBI->getOperand(1));
92+
.add(MBBI->getOperand(1))
93+
.setMIFlag(MachineInstr::FrameDestroy);
9394

9495
// Copy over the variable implicit uses and defs from the CM_POP. They depend
9596
// on what register list has been picked during frame lowering.

llvm/test/CodeGen/RISCV/xqccmp-cm-popretz.mir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ body: |
1717
; CHECK-XQCCMP32-NEXT: frame-setup CFI_INSTRUCTION offset $x8, -8
1818
; CHECK-XQCCMP32-NEXT: $x1 = IMPLICIT_DEF
1919
; CHECK-XQCCMP32-NEXT: $x8 = IMPLICIT_DEF
20-
; CHECK-XQCCMP32-NEXT: QC_CM_POPRET 5, 0, implicit-def $x2, implicit $x2, implicit-def $x1, implicit-def $x8
20+
; CHECK-XQCCMP32-NEXT: frame-destroy QC_CM_POPRET 5, 0, implicit-def $x2, implicit $x2, implicit-def $x1, implicit-def $x8
2121
;
2222
; CHECK-XQCCMP64-LABEL: name: popret_rvlist5
2323
; CHECK-XQCCMP64: liveins: $x1, $x8
@@ -28,7 +28,7 @@ body: |
2828
; CHECK-XQCCMP64-NEXT: frame-setup CFI_INSTRUCTION offset $x8, -16
2929
; CHECK-XQCCMP64-NEXT: $x1 = IMPLICIT_DEF
3030
; CHECK-XQCCMP64-NEXT: $x8 = IMPLICIT_DEF
31-
; CHECK-XQCCMP64-NEXT: QC_CM_POPRET 5, 0, implicit-def $x2, implicit $x2, implicit-def $x1, implicit-def $x8
31+
; CHECK-XQCCMP64-NEXT: frame-destroy QC_CM_POPRET 5, 0, implicit-def $x2, implicit $x2, implicit-def $x1, implicit-def $x8
3232
$x1 = IMPLICIT_DEF
3333
$x8 = IMPLICIT_DEF
3434
PseudoRET
@@ -47,7 +47,7 @@ body: |
4747
; CHECK-XQCCMP32-NEXT: frame-setup CFI_INSTRUCTION offset $x8, -8
4848
; CHECK-XQCCMP32-NEXT: $x1 = IMPLICIT_DEF
4949
; CHECK-XQCCMP32-NEXT: $x8 = IMPLICIT_DEF
50-
; CHECK-XQCCMP32-NEXT: QC_CM_POPRETZ 5, 0, implicit-def $x2, implicit-def $x10, implicit $x2, implicit-def $x1, implicit-def $x8
50+
; CHECK-XQCCMP32-NEXT: frame-destroy QC_CM_POPRETZ 5, 0, implicit-def $x2, implicit-def $x10, implicit $x2, implicit-def $x1, implicit-def $x8
5151
;
5252
; CHECK-XQCCMP64-LABEL: name: popretz_rvlist5
5353
; CHECK-XQCCMP64: liveins: $x1, $x8
@@ -58,7 +58,7 @@ body: |
5858
; CHECK-XQCCMP64-NEXT: frame-setup CFI_INSTRUCTION offset $x8, -16
5959
; CHECK-XQCCMP64-NEXT: $x1 = IMPLICIT_DEF
6060
; CHECK-XQCCMP64-NEXT: $x8 = IMPLICIT_DEF
61-
; CHECK-XQCCMP64-NEXT: QC_CM_POPRETZ 5, 0, implicit-def $x2, implicit-def $x10, implicit $x2, implicit-def $x1, implicit-def $x8
61+
; CHECK-XQCCMP64-NEXT: frame-destroy QC_CM_POPRETZ 5, 0, implicit-def $x2, implicit-def $x10, implicit $x2, implicit-def $x1, implicit-def $x8
6262
$x1 = IMPLICIT_DEF
6363
$x8 = IMPLICIT_DEF
6464
$x10 = COPY $x0

llvm/test/CodeGen/RISCV/zcmp-cm-popretz.mir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ body: |
2525
; CHECK-ZCMP32-NEXT: frame-setup CFI_INSTRUCTION offset $x8, -4
2626
; CHECK-ZCMP32-NEXT: $x1 = IMPLICIT_DEF
2727
; CHECK-ZCMP32-NEXT: $x8 = IMPLICIT_DEF
28-
; CHECK-ZCMP32-NEXT: CM_POPRET 5, 0, implicit-def $x2, implicit $x2, implicit-def $x1, implicit-def $x8
28+
; CHECK-ZCMP32-NEXT: frame-destroy CM_POPRET 5, 0, implicit-def $x2, implicit $x2, implicit-def $x1, implicit-def $x8
2929
;
3030
; CHECK-LIBCALL32-LABEL: name: popret_rvlist5
3131
; CHECK-LIBCALL32: liveins: $x1, $x8
@@ -47,7 +47,7 @@ body: |
4747
; CHECK-ZCMP64-NEXT: frame-setup CFI_INSTRUCTION offset $x8, -8
4848
; CHECK-ZCMP64-NEXT: $x1 = IMPLICIT_DEF
4949
; CHECK-ZCMP64-NEXT: $x8 = IMPLICIT_DEF
50-
; CHECK-ZCMP64-NEXT: CM_POPRET 5, 0, implicit-def $x2, implicit $x2, implicit-def $x1, implicit-def $x8
50+
; CHECK-ZCMP64-NEXT: frame-destroy CM_POPRET 5, 0, implicit-def $x2, implicit $x2, implicit-def $x1, implicit-def $x8
5151
;
5252
; CHECK-LIBCALL64-LABEL: name: popret_rvlist5
5353
; CHECK-LIBCALL64: liveins: $x1, $x8
@@ -115,7 +115,7 @@ body: |
115115
; CHECK-ZCMP32-NEXT: frame-setup CFI_INSTRUCTION offset $x8, -4
116116
; CHECK-ZCMP32-NEXT: $x1 = IMPLICIT_DEF
117117
; CHECK-ZCMP32-NEXT: $x8 = IMPLICIT_DEF
118-
; CHECK-ZCMP32-NEXT: CM_POPRETZ 5, 0, implicit-def $x2, implicit-def $x10, implicit $x2, implicit-def $x1, implicit-def $x8
118+
; CHECK-ZCMP32-NEXT: frame-destroy CM_POPRETZ 5, 0, implicit-def $x2, implicit-def $x10, implicit $x2, implicit-def $x1, implicit-def $x8
119119
;
120120
; CHECK-LIBCALL32-LABEL: name: popretz_rvlist5
121121
; CHECK-LIBCALL32: liveins: $x1, $x8
@@ -138,7 +138,7 @@ body: |
138138
; CHECK-ZCMP64-NEXT: frame-setup CFI_INSTRUCTION offset $x8, -8
139139
; CHECK-ZCMP64-NEXT: $x1 = IMPLICIT_DEF
140140
; CHECK-ZCMP64-NEXT: $x8 = IMPLICIT_DEF
141-
; CHECK-ZCMP64-NEXT: CM_POPRETZ 5, 0, implicit-def $x2, implicit-def $x10, implicit $x2, implicit-def $x1, implicit-def $x8
141+
; CHECK-ZCMP64-NEXT: frame-destroy CM_POPRETZ 5, 0, implicit-def $x2, implicit-def $x10, implicit $x2, implicit-def $x1, implicit-def $x8
142142
;
143143
; CHECK-LIBCALL64-LABEL: name: popretz_rvlist5
144144
; CHECK-LIBCALL64: liveins: $x1, $x8

0 commit comments

Comments
 (0)