Skip to content

[BUG]: Rust "LLVM IR" view seems to ignore (some?) compiler flags #8203

@RalfJung

Description

@RalfJung

Describe the bug

When setting flags in the "compiler" tab that should affect the LLVM IR view, those flag seem to be ignored.

Steps to reproduce

  1. Choose nightly rustc as the compiler
  2. add the -Zfewer-names=true flag
  3. add an LLVM IR window

I used this code:

const C: (&u32, &u32) = {
    let x = &(0xaaaaaaaa, 0xbbbbbbbb);
    (&x.0, &x.1)
};

#[unsafe(no_mangle)]
pub fn get1() -> &'static u32 {
    C.0
}
#[unsafe(no_mangle)]
pub fn get2() -> &'static u32 {
    C.1
}

Expected behavior

The flag should affect the name of the global in LLVM IR. By default, it's alloc_c9bf22225d4343a4b04cfb9efe779ab0, but with the flag it should become something like anon.bb9f785fef94f15b27153a454d937760.0. I confirmed this locally by building that code with --emit=llvm-ir -Zfewer-names=true --crate-type=lib.

However, on godbolt the name in the LLVM IR view is always `alloc_c9bf22225d4343a4b04cfb9efe779ab0.

Reproduction link

https://rust.godbolt.org/z/bfbY73jsa

Screenshots

Not applicable

Operating System

No response

Browser version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugliveThis is now live

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions