Don't inline function containing OpKill (#2842)
If an OpKill instruction is inlined into a continue construct, then the
spir-v is no longer valid. To avoid this issue, we do inline into an
OpKill at all. This method was chosen because it is difficult to keep
track of whether or not you are in a continue construct while changing
the function that is being inlined into. This will work well with wrap
OpKill because every will still be inlined except for the OpKill
instruction itself.
Fixes #2554
Fixes #2433
This reverts commit aa9e8f538041db3055ea443080e0ccc315fa114f.
diff --git a/source/opt/inline_pass.cpp b/source/opt/inline_pass.cpp
index f348bbe..98daaf4 100644
--- a/source/opt/inline_pass.cpp
+++ b/source/opt/inline_pass.cpp
@@ -720,6 +720,15 @@
return false;
}
+ // Do not inline functions with an OpKill because they may be inlined into a
+ // continue construct.
+ bool has_opkill = !func->WhileEachInst(
+ [](Instruction* inst) { return inst->opcode() != SpvOpKill; });
+
+ if (has_opkill) {
+ return false;
+ }
+
return true;
}