[asm] Remove explicit branch for modifier 'l'

No intended behavior change.

EmitGCCInlineAsmStr() used to explicitly check for modifier 'l'
after handling block address and machine basic block operands.
This prevented passing a MachineOperand with 'l' modifier to
PrintAsmMemoryOperand(). Conceptually that seems kind of nice,
but in practice the overrides of PrintAsmMemoryOperand() in all (*)
AsmPrinter subclasses already reject modifiers they don't know about,
and none of them don't know about 'l'. So removing this doesn't have
a behavior difference, is less code, and it makes EmitGCCInlineAsmStr()
and EmitMSInlineAsmStr() more similar, to prepare for merging them later.

(Why not _add_ the branch to EmitMSInlineAsmStr() instead? Because that
always works with X86AsmPrinter I think, and
X86AsmPrinter::PrintAsmMemoryOperand() very decisively rejects the 'l'
modifier, so it's hard to motivate adding that branch.)

*: The one exception was AVRAsmPrinter, which had an llvm_unreachable instead
of returning true. So this commit changes that, so that the AVR target keeps
emitting an error instead of crashing when passing a mem operand with a :l
modifier to it. All the other targets already don't crash on this.

Differential Revision: https://reviews.llvm.org/D114216
This commit is contained in:
Nico Weber 2021-11-18 22:50:42 -05:00
parent 6623c02d70
commit 4f9a5c2a14
3 changed files with 12 additions and 5 deletions

View File

@ -453,8 +453,6 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
} else if (MI->getOperand(OpNo).isMBB()) { } else if (MI->getOperand(OpNo).isMBB()) {
const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol(); const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
Sym->print(OS, AP->MAI); Sym->print(OS, AP->MAI);
} else if (Modifier[0] == 'l') {
Error = true;
} else if (InlineAsm::isMemKind(OpFlags)) { } else if (InlineAsm::isMemKind(OpFlags)) {
Error = AP->PrintAsmMemoryOperand( Error = AP->PrintAsmMemoryOperand(
MI, OpNo, Modifier[0] ? Modifier : nullptr, OS); MI, OpNo, Modifier[0] ? Modifier : nullptr, OS);

View File

@ -144,9 +144,8 @@ bool AVRAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
bool AVRAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, bool AVRAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
unsigned OpNum, const char *ExtraCode, unsigned OpNum, const char *ExtraCode,
raw_ostream &O) { raw_ostream &O) {
if (ExtraCode && ExtraCode[0]) { if (ExtraCode && ExtraCode[0])
llvm_unreachable("This branch is not implemented yet"); return true; // Unknown modifier
}
const MachineOperand &MO = MI->getOperand(OpNum); const MachineOperand &MO = MI->getOperand(OpNum);
(void)MO; (void)MO;

View File

@ -0,0 +1,10 @@
; RUN: not llc < %s -march=avr -no-integrated-as 2>&1 | FileCheck %s
define void @foo(i16 %a) {
; CHECK: error: invalid operand in inline asm: 'jl ${0:l}'
%i.addr = alloca i32, align 4
call void asm sideeffect "jl ${0:l}", "*m"(i32* %i.addr)
ret void
}