codegen: add handling for undefined phinode values#45155
Conversation
|
I pushed a test to this. |
test/compiler/codegen.jl
Outdated
|
|
||
| mktemp() do f_44501, _ | ||
| write(f_44501, str_44501) | ||
| @test success(`$(Base.julia_cmd()) --startup-file=no -O0 $f_44501`) |
There was a problem hiding this comment.
why is this launching a process to run a test? we don't do that normally
There was a problem hiding this comment.
Because it needs -O0 to repro.
There was a problem hiding this comment.
That generally just means it is a bad test, but you don't need a new process for that either as there is Base.Experimental.@compiler_options optimize=0
There was a problem hiding this comment.
It's the test I have for now. I'll try with the option instead, good idea.
There was a problem hiding this comment.
I tried with that but it didn't repro with it. Feel free to change/remove this test.
There was a problem hiding this comment.
Ultimately our ssa-conversion optimization pass is doing a bad job here, so this test is not expected to be reliable. We don't really have a good way to unit-test just the codegen part however for weird IR forms like this.
The optimization pass often uses values for phi values (and thus by extension, also for pi, phic and upsilon values) that are invalid. We make sure that these have a null pointer, so that we can detect that case at runtime (at the cost of slightly worse code generation for them), but it means we need to be very careful to check for that. This is identical to #39747, which added the equivalent code to the other side of the conditional there, but missed some additional relevant, but rare, cases that are observed to be possible. The `emit_isa_and_defined` is derived from the LLVM name for this operation: `isa_and_nonnull<T>`. Secondly, we also optimize `emit_unionmove` to change a bad IR case to a better IR form. Fix #44501
The optimization pass often uses values for phi values (and thus by extension, also for pi, phic and upsilon values) that are invalid. We make sure that these have a null pointer, so that we can detect that case at runtime (at the cost of slightly worse code generation for them), but it means we need to be very careful to check for that. This is identical to #39747, which added the equivalent code to the other side of the conditional there, but missed some additional relevant, but rare, cases that are observed to be possible. The `emit_isa_and_defined` is derived from the LLVM name for this operation: `isa_and_nonnull<T>`. Secondly, we also optimize `emit_unionmove` to change a bad IR case to a better IR form. Fix #44501 (cherry picked from commit 72b80e2)
The optimization pass often uses values for phi values (and thus by extension, also for pi, phic and upsilon values) that are invalid. We make sure that these have a null pointer, so that we can detect that case at runtime (at the cost of slightly worse code generation for them), but it means we need to be very careful to check for that. This is identical to #39747, which added the equivalent code to the other side of the conditional there, but missed some additional relevant, but rare, cases that are observed to be possible. The `emit_isa_and_defined` is derived from the LLVM name for this operation: `isa_and_nonnull<T>`. Secondly, we also optimize `emit_unionmove` to change a bad IR case to a better IR form. Fix #44501 (cherry picked from commit 72b80e2)
The optimization pass often uses values for phi values (and thus by
extension, also for pi, phic and upsilon values) that are invalid. We
make sure that these have a null pointer, so that we can detect that
case at runtime (at the cost of slightly worse code generation for
them), but it means we need to be very careful to check for that.
This is identical to #39747, which added the equivalent code to the
other side of the conditional there, but missed some additional
relevant, but rare, cases that are observed to be possible.
The
emit_isa_and_definedis derived from the LLVM name for thisoperation:
isa_and_nonnull<T>.Secondly, we also optimize
emit_unionmoveto change a bad IR case to abetter IR form.
Fix #44501