This is an archive of the discontinued LLVM Phabricator instance.

[asm] Allow labels as operands in intel asm syntax
ClosedPublic

Authored by thakis on Nov 20 2021, 7:12 PM.

Details

Summary

This makes a line in llvm/test/CodeGen/X86/asm-block-labels.ll pass
with asm inteldialect too.

I don't know if this is something one can hit in practice with inline
asm. The test is from 2007 (4646aa3e337aa) but in 2009 blockaddr was
introduced and e.g. __asm__ __volatile__("brl %0" :: "X"(&&foo) : "memory");
compiles to

call void asm sideeffect "brl $0", "X,..."(i8* blockaddress(@func, %1))

nowadays (thanks to jrtc27 for that example!).

(6c4d255bf3d64 switched clang to blockaddress on an opt-in basis,
e4801f7844bb added docs for it, 31b132c0b781 added IR support.)

I half-heartedly tried to build clang 2.8 locally, but it didn't
just build. And 2.8 didn't have a prebuilt clang binary yet.

The motivation is to make EmitGCCInlineAsmStr() and EmitMSInlineAsmStr()
more alike, and maybe we should delete this code form EmitGCCInlineAsmStr()
instead. But since it's just 3 lines and it's reachable from LLVM IR,
let's do the safer thing for now.

Diff Detail

Event Timeline

thakis created this revision.Nov 20 2021, 7:12 PM
thakis requested review of this revision.Nov 20 2021, 7:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 20 2021, 7:12 PM
hans accepted this revision.Nov 22 2021, 5:57 AM

lgtm

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