Skip to content

Commit 42204c9

Browse files
committed
Revert "[TargetInstrInfo] enable foldMemoryOperand for InlineAsm (#70743)"
This reverts commit 99ee2db. It's causing ICEs in the ARM tests. See the comment here: 99ee2db
1 parent 23c47eb commit 42204c9

File tree

2 files changed

+0
-72
lines changed

2 files changed

+0
-72
lines changed

llvm/include/llvm/CodeGen/TargetInstrInfo.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,16 +2188,6 @@ class TargetInstrInfo : public MCInstrInfo {
21882188
// Get the call frame size just before MI.
21892189
unsigned getCallFrameSizeAt(MachineInstr &MI) const;
21902190

2191-
/// Fills in the necessary MachineOperands to refer to a frame index.
2192-
/// The best way to understand this is to print `asm(""::"m"(x));` after
2193-
/// finalize-isel. Example:
2194-
/// INLINEASM ... 262190 /* mem:m */, %stack.0.x.addr, 1, $noreg, 0, $noreg
2195-
/// we would add placeholders for: ^ ^ ^ ^
2196-
virtual void
2197-
getFrameIndexOperands(SmallVectorImpl<MachineOperand> &Ops) const {
2198-
llvm_unreachable("unknown number of operands necessary");
2199-
}
2200-
22012191
private:
22022192
mutable std::unique_ptr<MIRFormatter> Formatter;
22032193
unsigned CallFrameSetupOpcode, CallFrameDestroyOpcode;

llvm/lib/CodeGen/TargetInstrInfo.cpp

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -565,64 +565,6 @@ static MachineInstr *foldPatchpoint(MachineFunction &MF, MachineInstr &MI,
565565
return NewMI;
566566
}
567567

568-
static void foldInlineAsmMemOperand(MachineInstr *MI, unsigned OpNo, int FI,
569-
const TargetInstrInfo &TII) {
570-
MachineOperand &MO = MI->getOperand(OpNo);
571-
const VirtRegInfo &RI = AnalyzeVirtRegInBundle(*MI, MO.getReg());
572-
573-
// If the machine operand is tied, untie it first.
574-
if (MO.isTied()) {
575-
unsigned TiedTo = MI->findTiedOperandIdx(OpNo);
576-
MI->untieRegOperand(OpNo);
577-
// Intentional recursion!
578-
foldInlineAsmMemOperand(MI, TiedTo, FI, TII);
579-
}
580-
581-
// Change the operand from a register to a frame index.
582-
MO.ChangeToFrameIndex(FI, MO.getTargetFlags());
583-
584-
SmallVector<MachineOperand, 4> NewOps;
585-
TII.getFrameIndexOperands(NewOps);
586-
assert(!NewOps.empty() && "getFrameIndexOperands didn't create any operands");
587-
MI->insert(MI->operands_begin() + OpNo + 1, NewOps);
588-
589-
// Change the previous operand to a MemKind InlineAsm::Flag. The second param
590-
// is the per-target number of operands that represent the memory operand
591-
// excluding this one (MD). This includes MO.
592-
InlineAsm::Flag F(InlineAsm::Kind::Mem, NewOps.size() + 1);
593-
F.setMemConstraint(InlineAsm::ConstraintCode::m);
594-
MachineOperand &MD = MI->getOperand(OpNo - 1);
595-
MD.setImm(F);
596-
597-
// Update mayload/maystore metadata.
598-
MachineOperand &ExtraMO = MI->getOperand(InlineAsm::MIOp_ExtraInfo);
599-
if (RI.Reads)
600-
ExtraMO.setImm(ExtraMO.getImm() | InlineAsm::Extra_MayLoad);
601-
if (RI.Writes)
602-
ExtraMO.setImm(ExtraMO.getImm() | InlineAsm::Extra_MayStore);
603-
}
604-
605-
// Returns nullptr if not possible to fold.
606-
static MachineInstr *foldInlineAsmMemOperand(MachineInstr &MI,
607-
ArrayRef<unsigned> Ops, int FI,
608-
const TargetInstrInfo &TII) {
609-
assert(MI.isInlineAsm() && "wrong opcode");
610-
if (Ops.size() > 1)
611-
return nullptr;
612-
unsigned Op = Ops[0];
613-
assert(Op && "should never be first operand");
614-
assert(MI.getOperand(Op).isReg() && "shouldn't be folding non-reg operands");
615-
616-
if (!MI.mayFoldInlineAsmRegOp(Op))
617-
return nullptr;
618-
619-
MachineInstr &NewMI = TII.duplicate(*MI.getParent(), MI.getIterator(), MI);
620-
621-
foldInlineAsmMemOperand(&NewMI, Op, FI, TII);
622-
623-
return &NewMI;
624-
}
625-
626568
MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
627569
ArrayRef<unsigned> Ops, int FI,
628570
LiveIntervals *LIS,
@@ -670,8 +612,6 @@ MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
670612
NewMI = foldPatchpoint(MF, MI, Ops, FI, *this);
671613
if (NewMI)
672614
MBB->insert(MI, NewMI);
673-
} else if (MI.isInlineAsm()) {
674-
NewMI = foldInlineAsmMemOperand(MI, Ops, FI, *this);
675615
} else {
676616
// Ask the target to do the actual folding.
677617
NewMI = foldMemoryOperandImpl(MF, MI, Ops, MI, FI, LIS, VRM);
@@ -743,8 +683,6 @@ MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
743683
NewMI = foldPatchpoint(MF, MI, Ops, FrameIndex, *this);
744684
if (NewMI)
745685
NewMI = &*MBB.insert(MI, NewMI);
746-
} else if (MI.isInlineAsm() && isLoadFromStackSlot(LoadMI, FrameIndex)) {
747-
NewMI = foldInlineAsmMemOperand(MI, Ops, FrameIndex, *this);
748686
} else {
749687
// Ask the target to do the actual folding.
750688
NewMI = foldMemoryOperandImpl(MF, MI, Ops, MI, LoadMI, LIS);

0 commit comments

Comments
 (0)