Skip to content

asm!: lint on bare memory accesses without [] or offset #80058

Open
@joshtriplett

Description

@joshtriplett

In Intel syntax mode without prefixes, writing mov rax, some_symbol is equivalent to mov rax, [some_symbol]: in both cases it refers to the memory pointed to by the symbol. However, I've seen multiple people think the former syntax obtains the address of the symbol instead. (Referring to the address of the symbol requires offset, which doesn't currently work in LLVM.) This confusion can result in bugs that are quite difficult to debug.

I think it'd be appropriate, working in conjunction with a future version of LLVM's assembly parser, to catch "bare" uses of symbols, and suggest either adding [] around it to access the memory pointed to by the symbol, or adding offset to use the address of the symbol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-inline-assemblyArea: Inline assembly (`asm!(…)`)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.F-asm`#![feature(asm)]` (not `llvm_asm`)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions