Skip to content

?godbolt command #22

Description

@kangalio

This would be very convenient to quickly check what a piece of Rust code actually does, or if the Rust compiler generates code as intended.

?godbolt

pub fn foo(x: u32) -> u32 {
    x * 4 + 3
}

...will print...

example::foo:
       lea     eax, [4*rdi + 3]
       ret

By default, it would build on release mode (-Copt-level=3). Maybe we could introduce a ?godboltdebug command, but tbh I doubt that there is much use for such thing.

It might be good to allow custom rustc args, to better explore codegen. For example

?godbolt -Ctarget-cpu=native ``​`rs
pub fn foo(s: &mut [u32]) {
    for elem in s {
        *elem *= 2;
    }
}``​`

Godbolt has an API that can be used to implement all of this: https://github.com/compiler-explorer/compiler-explorer/blob/master/docs/API.md#post-apicompilercompiler-idcompile---perform-a-compilation-1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions