Skip to content

Commit 84ef8f8

Browse files
[AArch64] Fix incorrectly getting the destination reg of an insn
1 parent 533a229 commit 84ef8f8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4112,6 +4112,7 @@ bool AArch64InstrInfo::isPairedLdSt(const MachineInstr &MI) {
41124112
}
41134113

41144114
const MachineOperand &AArch64InstrInfo::getLdStBaseOp(const MachineInstr &MI) {
4115+
assert(MI.mayLoadOrStore() && "Load or store instruction expected");
41154116
unsigned Idx =
41164117
AArch64InstrInfo::isPairedLdSt(MI) || AArch64InstrInfo::isPreLdSt(MI) ? 2
41174118
: 1;
@@ -4120,6 +4121,7 @@ const MachineOperand &AArch64InstrInfo::getLdStBaseOp(const MachineInstr &MI) {
41204121

41214122
const MachineOperand &
41224123
AArch64InstrInfo::getLdStOffsetOp(const MachineInstr &MI) {
4124+
assert(MI.mayLoadOrStore() && "Load or store instruction expected");
41234125
unsigned Idx =
41244126
AArch64InstrInfo::isPairedLdSt(MI) || AArch64InstrInfo::isPreLdSt(MI) ? 3
41254127
: 2;

llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,7 +1956,7 @@ maybeMoveCFI(MachineInstr &MI, MachineBasicBlock::iterator MaybeCFI) {
19561956
MaybeCFI->getOpcode() != TargetOpcode::CFI_INSTRUCTION ||
19571957
!(MI.getFlag(MachineInstr::FrameSetup) ||
19581958
MI.getFlag(MachineInstr::FrameDestroy)) ||
1959-
AArch64InstrInfo::getLdStBaseOp(MI).getReg() != AArch64::SP)
1959+
MI.getOperand(0).getReg() != AArch64::SP)
19601960
return End;
19611961

19621962
const MachineFunction &MF = *MI.getParent()->getParent();
@@ -2006,7 +2006,7 @@ AArch64LoadStoreOpt::mergeUpdateInsn(MachineBasicBlock::iterator I,
20062006
if (!AArch64InstrInfo::isPairedLdSt(*I)) {
20072007
// Non-paired instruction.
20082008
MIB = BuildMI(*I->getParent(), I, I->getDebugLoc(), TII->get(NewOpc))
2009-
.add(getLdStRegOp(*Update))
2009+
.add(Update->getOperand(0))
20102010
.add(getLdStRegOp(*I))
20112011
.add(AArch64InstrInfo::getLdStBaseOp(*I))
20122012
.addImm(Value / Scale)
@@ -2015,7 +2015,7 @@ AArch64LoadStoreOpt::mergeUpdateInsn(MachineBasicBlock::iterator I,
20152015
} else {
20162016
// Paired instruction.
20172017
MIB = BuildMI(*I->getParent(), I, I->getDebugLoc(), TII->get(NewOpc))
2018-
.add(getLdStRegOp(*Update))
2018+
.add(Update->getOperand(0))
20192019
.add(getLdStRegOp(*I, 0))
20202020
.add(getLdStRegOp(*I, 1))
20212021
.add(AArch64InstrInfo::getLdStBaseOp(*I))

0 commit comments

Comments
 (0)