ART: Fix IsLinearOrderWellFormed in liveness analysis

Graph may contain nullptr in list of basic blocks when
the basic block is removed. So we must handle nullptr explicitly.

Bug: 28252537
Bug: 27615840
Bug: 27624868

Change-Id: If430939b8fe793e4a9c974936180d06c1a9f90c6
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
(cherry picked from commit fa3091ef031da6c18478fdede12d7762634ee271)
diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h
index 719feec..40dab74 100644
--- a/compiler/optimizing/ssa_liveness_analysis.h
+++ b/compiler/optimizing/ssa_liveness_analysis.h
@@ -971,7 +971,7 @@
 
   bool IsLinearOrderWellFormed(const HGraph& graph) {
     for (HBasicBlock* header : graph.GetBlocks()) {
-      if (!header->IsLoopHeader()) {
+      if (header == nullptr || !header->IsLoopHeader()) {
         continue;
       }
 
diff --git a/test/594-checker-irreducible-linorder/smali/IrreducibleLoop.smali b/test/594-checker-irreducible-linorder/smali/IrreducibleLoop.smali
index 8e01084..366c7b9 100644
--- a/test/594-checker-irreducible-linorder/smali/IrreducibleLoop.smali
+++ b/test/594-checker-irreducible-linorder/smali/IrreducibleLoop.smali
@@ -40,6 +40,11 @@
    invoke-static {v0}, Ljava/lang/System;->exit(I)V
    goto :body1
 
+   # Trivially dead code to ensure linear order verification skips removed blocks (b/28252537).
+   :dead_code
+   nop
+   goto :dead_code
+
    :header
    mul-int/2addr p3, p3
    if-eqz p1, :body2