This is an archive of the discontinued LLVM Phabricator instance.

[X86][CodeGen] Do not add `offset` for memory reference using symbol
ClosedPublic

Authored by alvinhochun on May 6 2023, 11:39 AM.

Details

Summary

In the past, D71436 added writing the offset operator for some
legitimate cases. However, for memory references in Intel syntax, the
offset operator ([offset sym]) appears to be superfluous at best,
possibly wrong and contradictory at worst.

This patch bypasses writing the offset operator in
X86AsmPrinter::PrintIntelMemReference which affects exactly this
case. A similar code flow exists in X86IntelInstPrinter.cpp -
X86IntelInstPrinter::printMemReference.

The motivation for fixing this output is to allow us to reject the
confusing call [offset fn_ref] syntax in MC, as discussed in D149579.

Depends on D149579

Diff Detail

Event Timeline

alvinhochun created this revision.May 6 2023, 11:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2023, 11:39 AM
alvinhochun requested review of this revision.May 6 2023, 11:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2023, 11:39 AM
MaskRay accepted this revision.May 6 2023, 12:58 PM

Thanks!

llvm/test/CodeGen/X86/ms-inline-asm-functions.ll
2

Add a comment `;; Check that the generated memory references do not contain the offset` operator. Use -no-integrated-as to disable AsmParser formatting.``

4

;; for non-CHECK non-RUN lines. This marker may help (future) auto tools to retain the comments.

94

Clean up unneeded attributes and metadata to reduce noise.

This revision is now accepted and ready to land.May 6 2023, 12:58 PM
MaskRay added inline comments.May 6 2023, 1:01 PM
llvm/test/CodeGen/X86/ms-inline-asm-functions.ll
2

Perhaps add -x86-asm-syntax=intel beside -no-integrated-as to output Intel syntax consistently.

alvinhochun added inline comments.May 7 2023, 2:59 AM
llvm/test/CodeGen/X86/ms-inline-asm-functions.ll
2

It doesn't seem to make a difference to the output of the inline assembly sections.

Apply suggestions.