Skip to content

zero_alloca outputs invalid bitcode in some cases #843

@marijnh

Description

@marijnh

The following program results in an error like this when compiled:

alignment argument of memory intrinsics must be a constant int
  call void @llvm.memset.p0i8.i32(i8* %25, i8 0, i32 %92, i32 select (i1 icmp ult (i32 ptrtoint (i32* getelementptr ({ i1, i32 }* null, i64 0, i32 1) to i32), i32 1), i32 1, i32 ptrtoint (i32* getelementptr ({ i1, i32 }* null, i64 0, i32 1) to i32)), i1 false)
tag option<T> { some(T); none; }

fn foo<T>(x: &T) {
    let a = ~[some(x)];
    let _b <- a;
}

fn main() {
    foo(5);
}

The problem seems to be that LLVMIsConstant considers the select expression a constant, whereas the checker does not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions