[llvm] 4f9a5c2 - [asm] Remove explicit branch for modifier 'l'
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 19 06:20:02 PST 2021
Author: Nico Weber
Date: 2021-11-19T09:19:53-05:00
New Revision: 4f9a5c2a1438c719f30f384c6bd9ac9290b882c0
URL: https://github.com/llvm/llvm-project/commit/4f9a5c2a1438c719f30f384c6bd9ac9290b882c0
DIFF: https://github.com/llvm/llvm-project/commit/4f9a5c2a1438c719f30f384c6bd9ac9290b882c0.diff
LOG: [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
Added:
llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
llvm/lib/Target/AVR/AVRAsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index 2c53eade6cd59..b12437b2afed6 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -453,8 +453,6 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
} else if (MI->getOperand(OpNo).isMBB()) {
const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
Sym->print(OS, AP->MAI);
- } else if (Modifier[0] == 'l') {
- Error = true;
} else if (InlineAsm::isMemKind(OpFlags)) {
Error = AP->PrintAsmMemoryOperand(
MI, OpNo, Modifier[0] ? Modifier : nullptr, OS);
diff --git a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
index 73f0a0961d6bd..259ab1bc7aec7 100644
--- a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
+++ b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
@@ -144,9 +144,8 @@ bool AVRAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
bool AVRAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
unsigned OpNum, const char *ExtraCode,
raw_ostream &O) {
- if (ExtraCode && ExtraCode[0]) {
- llvm_unreachable("This branch is not implemented yet");
- }
+ if (ExtraCode && ExtraCode[0])
+ return true; // Unknown modifier
const MachineOperand &MO = MI->getOperand(OpNum);
(void)MO;
diff --git a/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll b/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
new file mode 100644
index 0000000000000..81b0f6e9b2832
--- /dev/null
+++ b/llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
@@ -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
+}
+
More information about the llvm-commits
mailing list