Skip to content

Assembly comments affect generated code. #3298

Closed
@jld

Description

@jld

Given this program:

fn main() {
        let x = @3;
        let mut a = 0;
        for uint::range(1, *x) |_i| {
                a += 1;
        }
        assert(a == 2);
}

compiling with -S -O yields an assembly file containing this, which is what's left of the uint::range loop (as output by grep -C2 inc):

        .align  16, 0x90
.LBB2_4:
        incq    %rcx
        cmpq    %rcx, %rax
        jne     .LBB2_4

But compiling with -c -O and disassembling shows a file where the loop has been entirely removed. However, compiling with -S -Zno-asm-comments -O is faithful to the -c output; and with --save-temps we can see that the bitcode is identical between -c and -S -Zno-asm-comments and nontrivially different (more than just the comments) for -S.

So there's something about the asm comments that makes LLVM think they have effects.

Metadata

Metadata

Assignees

Labels

A-codegenArea: Code generationE-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.I-slowIssue: Problems and improvements with respect to performance of generated code.P-lowLow priority

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions