Skip to content

Invalid LLVM IR for certain iteration pattern #27594

Closed
@martinholters

Description

@martinholters

Reduced from the problem I've observed in #27434 (comment).

struct Iter end
Base.iterate(::Iter) = (1, nothing)
Base.iterate(::Iter, ::Any) = nothing

function foo()
    ind = 0
    for x in (1,)
        for y in Iter()
            ind += 1
        end
    end
end

code_llvm(foo, Tuple{})

gives

PHI node has multiple entries for the same basic block with different incoming values!
  %value_phi2 = phi i64 [ %36, %L11 ], [ %37, %L11 ], [ %value_phi, %L5.L13_crit_edge ]
label %L11
  %37 = load i64, i64* %8, align 8, !dbg !28, !tbaa !21
  %36 = load i64, i64* %8, align 8, !dbg !28, !tbaa !21
LLVM ERROR: Broken function found, compilation aborted!

Tentatively assigning @Keno whom I suspect to be the best one to fix this.

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions