diff options
| author | 2014-10-16 12:59:34 +0000 | |
|---|---|---|
| committer | 2014-10-16 12:59:35 +0000 | |
| commit | dd36b42837b78876eabe86b136474490e3d016cc (patch) | |
| tree | f23efd27c5f30665c4d826be374b0b8d0aab72d3 | |
| parent | 1604027a8a87fc100aa3b8899ad710c2f313ca45 (diff) | |
| parent | e161a2a60c0325793f04be42a0f05228955ecfdd (diff) | |
Merge "Do not remove NullChecks & BoundsChecks in HDeadCodeElimination."
| -rw-r--r-- | compiler/optimizing/dead_code_elimination.cc | 5 | ||||
| -rw-r--r-- | compiler/optimizing/nodes.h | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc index fe2adc77d0..5655544427 100644 --- a/compiler/optimizing/dead_code_elimination.cc +++ b/compiler/optimizing/dead_code_elimination.cc @@ -35,7 +35,10 @@ void DeadCodeElimination::Run() { for (i.Advance(); !i.Done(); i.Advance()) { HInstruction* inst = i.Current(); DCHECK(!inst->IsControlFlow()); - if (!inst->HasSideEffects() && !inst->HasUses() && !inst->IsSuspendCheck()) { + if (!inst->HasSideEffects() + && !inst->CanThrow() + && !inst->IsSuspendCheck() + && !inst->HasUses()) { block->RemoveInstruction(inst); } } diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 677a4f8591..c6eb806904 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -650,6 +650,7 @@ class HInstruction : public ArenaObject { virtual bool NeedsEnvironment() const { return false; } virtual bool IsControlFlow() const { return false; } + virtual bool CanThrow() const { return false; } bool HasSideEffects() const { return side_effects_.HasSideEffects(); } void AddUseAt(HInstruction* user, size_t index) { @@ -1642,6 +1643,8 @@ class HNullCheck : public HExpression<1> { virtual bool NeedsEnvironment() const { return true; } + virtual bool CanThrow() const { return true; } + uint32_t GetDexPc() const { return dex_pc_; } DECLARE_INSTRUCTION(NullCheck); @@ -1802,6 +1805,8 @@ class HBoundsCheck : public HExpression<2> { virtual bool NeedsEnvironment() const { return true; } + virtual bool CanThrow() const { return true; } + uint32_t GetDexPc() const { return dex_pc_; } DECLARE_INSTRUCTION(BoundsCheck); |