Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline assembler with jmp + "m" will emit wrong code #3609

Open
ikskuh opened this issue Nov 5, 2019 · 0 comments
Open

Inline assembler with jmp + "m" will emit wrong code #3609

ikskuh opened this issue Nov 5, 2019 · 0 comments
Labels
backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior miscompilation The compiler reports success but produces semantically incorrect code.
Milestone

Comments

@ikskuh
Copy link
Contributor

ikskuh commented Nov 5, 2019

export const symbol : [1]u32 = undefined;
pub fn main() void
{
    asm volatile("jmp %[mem]" : : [mem] "m" (symbol[0]));
}

this code will emit jmp -4(%rbp) which seems to be a stack reference instead of a ref to the global symbol. Using asm volatile("jmp symbol") will work.

LLVM Emit Output...<inline asm>:1:2: error: unknown use of instruction mnemonic without a size suffix
        jmp -4(%rbp)
        ^
LLVM ERROR: Error parsing inline asm

Zig Version: 0.5.0+55685ae78

Related: #3606

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior miscompilation The compiler reports success but produces semantically incorrect code. stage1 The process of building from source via WebAssembly and the C backend. labels Nov 27, 2019
@andrewrk andrewrk added this to the 0.6.0 milestone Nov 27, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Feb 21, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 17, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@Vexu Vexu added backend-llvm The LLVM backend outputs an LLVM IR Module. and removed stage1 The process of building from source via WebAssembly and the C backend. labels Dec 28, 2022
@andrewrk andrewrk modified the milestones: 0.14.0, 0.11.0, 0.11.1 Jul 22, 2023
@andrewrk andrewrk modified the milestones: 0.11.1, 0.12.0, 0.13.0 Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior miscompilation The compiler reports success but produces semantically incorrect code.
Projects
None yet
Development

No branches or pull requests

3 participants