Skip to content

Missing terminator inside if-else branch #95

@raffopazzo

Description

@raffopazzo

The following program generates invalid LLVM IR because a terminator is not emitted to jump out of the if-branch.

extern puts(cstr_t) -> i32_t;
func maybe_print_hello(bool_t x) mutable -> i32_t
{
    if (x)
        puts("hello");
    return 0;
}

The IR generated currently is something like

declare signext i32 @puts(i8* nonnull)
define signext i32 @maybe_print_hello(i1 zeroext %x) {
entry:
  br i1 %x, label %then, label %else

then:
  %0 = call i32 @puts(...)

else:
  br label %next

next:
  ret i32 0
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions