Skip to content

CC.populate_def_use_map! doesn't work as expected. #56193

Open
@jumerckx

Description

@jumerckx

MWE:

using Test

const CC = Core.Compiler

ir, ret = only(Base.code_ircode((Int, ); optimize_until="compact 1") do x
    y = 2*x
    return y
end)

tpdum = CC.TwoPhaseDefUseMap(length(ir.stmts));

CC.populate_def_use_map!(tpdum, ir)

@test !isempty(tpdum.data) # fails, tpdum is empty

The problem is the following, as described by @willtebbutt on Slack:

I'm a bit confused by the use of userefs in populate_def_use_map! , see here:

for ur in userefs(inst)

In particular:

  1. the argument to userefs is an Instruction, meaning that the relevant flag of the returned UseRefIterator will always be set to false.
  2. The relevant flag being false means that no iterations of the linked for loop will ever be performed.
  3. Therefore, calling populate_def_use_map does not appear to ever modify tpdum.

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