[PATCH] D46265: StackColoring: better handling of statically unreachable code

Than McIntosh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 30 07:01:06 PDT 2018


thanm created this revision.

Avoid assert/crash during liveness calculation in situations where the
incoming machine function has statically unreachable BBs.

Fixes PR37130.


Repository:
  rL LLVM

https://reviews.llvm.org/D46265

Files:
  lib/CodeGen/StackColoring.cpp


Index: lib/CodeGen/StackColoring.cpp
===================================================================
--- lib/CodeGen/StackColoring.cpp
+++ lib/CodeGen/StackColoring.cpp
@@ -779,8 +779,11 @@
       for (MachineBasicBlock::const_pred_iterator PI = BB->pred_begin(),
            PE = BB->pred_end(); PI != PE; ++PI) {
         LivenessMap::const_iterator I = BlockLiveness.find(*PI);
-        assert(I != BlockLiveness.end() && "Predecessor not found");
-        LocalLiveIn |= I->second.LiveOut;
+        // PR37130: transformations prior to stack coloring can
+        // sometimes leave behind statically unreachable blocks; these
+        // can be safely skipped here.
+        if (I != BlockLiveness.end())
+          LocalLiveIn |= I->second.LiveOut;
       }
 
       // Compute LiveOut by subtracting out lifetimes that end in this


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46265.144552.patch
Type: text/x-patch
Size: 842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180430/e9dab88c/attachment.bin>


More information about the llvm-commits mailing list