Skip to content

opt -O3 is not treating names correctly. #62471

@UltimatePea

Description

@UltimatePea

I have a machine generated .ll file that can be compiled correctly by llc. However, if I first optimize the program using opt, and then compile using llc, the compiler will complain multiple definition of local value named. I would think that there is either a bug in opt or in llc. As the program is machine generated by my compiler, I do not have a reduced test case yet.

I suspect the issue is that opt is inserting an incorrect amount of .i when trying to make sure the names do not clash, and unfortunately, it failed.

Steps to reproduce,

  1. Download the attached runtest.ll.txt and rename it to runtest.ll
  2. Run llc -o runtest.o runtest.ll and confirm it is successful
  3. Run opt -O3 -o runtest.opt.ll runtest.ll and confirm it is successful. The -O3 is crucial here.
  4. Run llc -o runtest.opt.o runtest.opt.ll and see the name clash.

runtest.ll.txt

Version information:
opt --version

Homebrew LLVM version 15.0.7
  Optimized build.
  Default target: x86_64-apple-darwin22.1.0
  Host CPU: skylake

llc --version

Homebrew LLVM version 15.0.7
  Optimized build.
  Default target: x86_64-apple-darwin22.1.0
  Host CPU: skylake

  Registered Targets:
    aarch64    - AArch64 (little endian)
    aarch64_32 - AArch64 (little endian ILP32)
    aarch64_be - AArch64 (big endian)
    amdgcn     - AMD GCN GPUs
    arm        - ARM
    arm64      - ARM64 (little endian)
    arm64_32   - ARM64 (little endian ILP32)
    armeb      - ARM (big endian)
    avr        - Atmel AVR Microcontroller
    bpf        - BPF (host endian)
    bpfeb      - BPF (big endian)
    bpfel      - BPF (little endian)
    hexagon    - Hexagon
    lanai      - Lanai
    mips       - MIPS (32-bit big endian)
    mips64     - MIPS (64-bit big endian)
    mips64el   - MIPS (64-bit little endian)
    mipsel     - MIPS (32-bit little endian)
    msp430     - MSP430 [experimental]
    nvptx      - NVIDIA PTX 32-bit
    nvptx64    - NVIDIA PTX 64-bit
    ppc32      - PowerPC 32
    ppc32le    - PowerPC 32 LE
    ppc64      - PowerPC 64
    ppc64le    - PowerPC 64 LE
    r600       - AMD GPUs HD2XXX-HD6XXX
    riscv32    - 32-bit RISC-V
    riscv64    - 64-bit RISC-V
    sparc      - Sparc
    sparcel    - Sparc LE
    sparcv9    - Sparc V9
    systemz    - SystemZ
    thumb      - Thumb
    thumbeb    - Thumb (big endian)
    ve         - VE
    wasm32     - WebAssembly 32-bit
    wasm64     - WebAssembly 64-bit
    x86        - 32-bit X86: Pentium-Pro and above
    x86-64     - 64-bit X86: EM64T and AMD64
    xcore      - XCore

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-reductionLarge reproducer that should be reduced into a simpler formtools:opt

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions