This is an archive of the discontinued LLVM Phabricator instance.

[asm] Remove explicit branch for modifier 'l'
ClosedPublic

Authored by thakis on Nov 18 2021, 7:58 PM.

Details

Summary

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.

Diff Detail

Event Timeline

thakis created this revision.Nov 18 2021, 7:58 PM
thakis requested review of this revision.Nov 18 2021, 7:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2021, 7:58 PM
thakis edited the summary of this revision. (Show Details)Nov 18 2021, 7:59 PM
thakis added inline comments.Nov 19 2021, 3:54 AM
llvm/test/CodeGen/AVR/inline-asm/inline-asm-invalid.ll
7

IR of this form can be emitted by clang for e.g. this (nonsensical) code:

void f(int i) { asm volatile("jmpl %0"::"m"(i):); }
hans accepted this revision.Nov 19 2021, 5:08 AM

lgtm

This revision is now accepted and ready to land.Nov 19 2021, 5:08 AM
This revision was automatically updated to reflect the committed changes.