aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere@qt.io>2024-01-31 09:48:06 +0100
committerOlivier De Cannière <olivier.decanniere@qt.io>2024-02-12 23:16:05 +0100
commiteb8834b65b790e219fa32873bcb7c991a69c293c (patch)
tree6c8d788667b3c4696f03736a0ce8e0d786dc244c
parent887649defd10b28001b69b74b32f1648104d605e (diff)
Compiler: Assert against noop instructions
The left-over instructions of QTBUG-109261 were only able to persist because the dead code analysis assumes that instructions aren't noops and because the StoreElement instruction was not marked as having side effects. Since a521216b7149185de9c82b9b6b34486dac8794a1, StoreElement has been marked as having side effects and the left-over instructions can thus no longer remain. The dead code elimination logic is thus fine as it is. Add an assert in QQmlJSTypePropagator::endInstruction() to prevent noop instructions in the future. Fixes: QTBUG-109261 Change-Id: Ida1a121f016c17954ac0005690c100b468378198 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 04c1588965b9a4b12ebf04b23e5336fe88bb4f56) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 06281a668fc2f83f56c498b6f8b893af868cb9f9) (cherry picked from commit 7f3466d1560c998c81d7a570e9ff47216d5fbf22)
-rw-r--r--src/qmlcompiler/qqmljstypepropagator.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljstypepropagator.cpp b/src/qmlcompiler/qqmljstypepropagator.cpp
index 3464cd058d..6cb33e3176 100644
--- a/src/qmlcompiler/qqmljstypepropagator.cpp
+++ b/src/qmlcompiler/qqmljstypepropagator.cpp
@@ -2191,6 +2191,7 @@ void QQmlJSTypePropagator::generate_InitializeBlockDeadTemporalZone(int firstReg
{
Q_UNUSED(firstReg)
Q_UNUSED(count)
+ m_state.setHasSideEffects(true);
// Ignore. We reject uninitialized values anyway.
}
@@ -2310,6 +2311,13 @@ void QQmlJSTypePropagator::endInstruction(QV4::Moth::Instr::Type instr)
}
}
+ if (!(m_error->isValid() && m_error->isError())
+ && instr != QV4::Moth::Instr::Type::DeadTemporalZoneCheck) {
+ // An instruction needs to have side effects or write to another register otherwise it's a
+ // noop. DeadTemporalZoneCheck is not needed by the compiler and is ignored.
+ Q_ASSERT(m_state.hasSideEffects() || m_state.changedRegisterIndex() != -1);
+ }
+
if (m_state.changedRegisterIndex() != InvalidRegister) {
Q_ASSERT(m_error->isValid() || m_state.changedRegister().isValid());
VirtualRegister &r = m_state.registers[m_state.changedRegisterIndex()];