[vm/compiler] Improve elimination of dead CatchBlockEntry Parameters
This change improves elimination of dead ParameterInstr instructions by skiping over Unbox instructions when tracing for real uses. Previously, ParameterInstr were removed if they we used only by other dead Parameters or as inputs to dead phis. Now, Unbox instructions are also allowed as long as they are also dead. TEST=vm/cc/TryCatchOptimizer_DeadParameterElimination_Cyclic1 (with sound null safety) Change-Id: Iba807ce43d10ff6e400abd614cc749d60f2454e1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212900 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Slava Egorov <vegorov@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
67ff459606
commit
c547e3e104
@@ -3914,7 +3914,7 @@ class TryCatchAnalyzer : public ValueObject {
|
||||
|
||||
for (auto phi : *join->phis()) {
|
||||
phi->mark_dead();
|
||||
if (HasNonPhiUse(phi)) {
|
||||
if (HasActualUse(phi)) {
|
||||
MarkLive(phi);
|
||||
}
|
||||
}
|
||||
@@ -3922,7 +3922,7 @@ class TryCatchAnalyzer : public ValueObject {
|
||||
}
|
||||
|
||||
for (auto info : parameter_info_) {
|
||||
if (HasNonPhiUse(info->instr)) {
|
||||
if (HasActualUse(info->instr)) {
|
||||
MarkLive(info->instr);
|
||||
}
|
||||
}
|
||||
@@ -3962,6 +3962,8 @@ class TryCatchAnalyzer : public ValueObject {
|
||||
worklist_.Add(param);
|
||||
}
|
||||
}
|
||||
} else if (UnboxInstr* unbox = defn->AsUnbox()) {
|
||||
MarkLive(unbox->value()->definition());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4003,10 +4005,16 @@ class TryCatchAnalyzer : public ValueObject {
|
||||
}
|
||||
|
||||
// Returns true if definition has a use in an instruction which is not a phi.
|
||||
static bool HasNonPhiUse(Definition* defn) {
|
||||
// Skip over Unbox instructions which may be inserted for unused phis.
|
||||
static bool HasActualUse(Definition* defn) {
|
||||
for (Value* use = defn->input_use_list(); use != nullptr;
|
||||
use = use->next_use()) {
|
||||
if (!use->instruction()->IsPhi()) {
|
||||
Instruction* use_instruction = use->instruction();
|
||||
if (UnboxInstr* unbox = use_instruction->AsUnbox()) {
|
||||
if (HasActualUse(unbox)) {
|
||||
return true;
|
||||
}
|
||||
} else if (!use_instruction->IsPhi()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user