From 4606a081c953d0adc64ac5d4181cfce958b53446 Mon Sep 17 00:00:00 2001 From: Subv Date: Fri, 20 Jul 2018 20:20:20 -0500 Subject: [PATCH] A64: The A64SetTPIDR IR instruction writes to a system register and should not be eliminated by the dead code elimination pass. Previously this instruction was alway eliminated, resulting in incorrect values for TPIDR_EL0. --- src/frontend/ir/microinstruction.cpp | 10 ++++++++++ src/frontend/ir/microinstruction.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/frontend/ir/microinstruction.cpp b/src/frontend/ir/microinstruction.cpp index 3a1e8f81..c24ad834 100644 --- a/src/frontend/ir/microinstruction.cpp +++ b/src/frontend/ir/microinstruction.cpp @@ -152,6 +152,15 @@ bool Inst::WritesToCPSR() const { } } +bool Inst::WritesToSystemRegister() const { + switch (op) { + case Opcode::A64SetTPIDR: + return true; + default: + return false; + } +} + bool Inst::ReadsFromCoreRegister() const { switch (op) { case Opcode::A32GetRegister: @@ -287,6 +296,7 @@ bool Inst::MayHaveSideEffects() const { op == Opcode::A64DataMemoryBarrier || CausesCPUException() || WritesToCoreRegister() || + WritesToSystemRegister() || WritesToCPSR() || WritesToFPSCR() || AltersExclusiveState() || diff --git a/src/frontend/ir/microinstruction.h b/src/frontend/ir/microinstruction.h index 2349797b..36a66083 100644 --- a/src/frontend/ir/microinstruction.h +++ b/src/frontend/ir/microinstruction.h @@ -55,6 +55,9 @@ public: /// Determines whether or not this instruction writes to the CPSR. bool WritesToCPSR() const; + /// Determines whether or not this instruction writes to a system register. + bool WritesToSystemRegister() const; + /// Determines whether or not this instruction reads from a core register. bool ReadsFromCoreRegister() const; /// Determines whether or not this instruction writes to a core register.