Skip to content

Conversation

@Keno
Copy link
Member

@Keno Keno commented Jun 7, 2021

PhiNode isn't really supported in lowered IR, but it is convenient
to be able to emit it, particularly for code that is designed to
perform transformations both on typed and on lowered IR (such as
Diffractor). Moreover, we do actually supported phinodes in untyped
IR both in the interpreter and in the compiler. At the moment,
inference assumes that PhiNodes get treated as embedded constants,
which is just not what the actual implementation does. At the very
least, it should just leave PhiNodes alone in case they accidentally
end up in lowered IR (rather than causing crashes), but we might
as well give them some basic support.

@femtomc
Copy link
Contributor

femtomc commented Jun 8, 2021

I've been wondering about this for a long long time -- this is great.

@Keno
Copy link
Member Author

Keno commented Jun 9, 2021

I have a couple more fixes here that I'll push shortly.

return (vtypes[slot_id(e)]::VarState).typ
elseif isa(e, GlobalRef)
return abstract_eval_global(e.mod, e.name)
elseif isa(e, PhiNode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to move this to abstract_eval_statement, since it can't be nested in anything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

deleteat!(sv.stmt_info, i)
nexpr -= 1
if oldidx < length(changemap)
changemap[oldidx + 1] = -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wha? Was this a bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the changemap was just offset by one, but as a result, nothing was recorded for the last statement, but here I do need to know if the last statement got deleted (so I can update the relevant phi nodes if any), so I changed the ordering to be non-offset.

@Keno Keno force-pushed the kf/phinodeinf branch 2 times, most recently from 3b71aa3 to 7a15866 Compare June 17, 2021 23:54
@Keno Keno closed this Jun 22, 2021
@Keno Keno reopened this Jun 22, 2021
PhiNode isn't really supported in lowered IR, but it is convenient
to be able to emit it, particularly for code that is designed to
perform transformations both on typed and on lowered IR (such as
Diffractor). Moreover, we do actually supported phinodes in untyped
IR both in the interpreter and in the compiler. At the moment,
inference assumes that PhiNodes get treated as embedded constants,
which is just not what the actual implementation does. At the very
least, it should just leave PhiNodes alone in case they accidentally
end up in lowered IR (rather than causing crashes), but we might
as well give them some basic support.
@JeffBezanson JeffBezanson added the merge me PR is reviewed. Merge when all tests are passing label Jun 23, 2021
@JeffBezanson JeffBezanson merged commit bb52621 into master Jun 24, 2021
@JeffBezanson JeffBezanson deleted the kf/phinodeinf branch June 24, 2021 02:47
@oscardssmith oscardssmith removed the merge me PR is reviewed. Merge when all tests are passing label Jun 24, 2021
@Keno
Copy link
Member Author

Keno commented Jun 26, 2021

Per discussion with the compiler team, I'd like to backport this to enable Diffractor and also because the previous behavior is quite arguable a bug.

KristofferC pushed a commit that referenced this pull request Jun 30, 2021
PhiNode isn't really supported in lowered IR, but it is convenient
to be able to emit it, particularly for code that is designed to
perform transformations both on typed and on lowered IR (such as
Diffractor). Moreover, we do actually supported phinodes in untyped
IR both in the interpreter and in the compiler. At the moment,
inference assumes that PhiNodes get treated as embedded constants,
which is just not what the actual implementation does. At the very
least, it should just leave PhiNodes alone in case they accidentally
end up in lowered IR (rather than causing crashes), but we might
as well give them some basic support.

(cherry picked from commit bb52621)
johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
PhiNode isn't really supported in lowered IR, but it is convenient
to be able to emit it, particularly for code that is designed to
perform transformations both on typed and on lowered IR (such as
Diffractor). Moreover, we do actually supported phinodes in untyped
IR both in the interpreter and in the compiler. At the moment,
inference assumes that PhiNodes get treated as embedded constants,
which is just not what the actual implementation does. At the very
least, it should just leave PhiNodes alone in case they accidentally
end up in lowered IR (rather than causing crashes), but we might
as well give them some basic support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants