From 48bf43df8a92057feaad1142d0e251f7a160ab12 Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Tue, 29 May 2018 13:52:24 +0000 Subject: StackColoring: better handling of statically unreachable code Summary: Avoid assert/crash during liveness calculation in situations where the incoming machine function has statically unreachable BBs. Second attempt at submitting; this version of the change includes a revised testcase. Fixes PR37130. Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D47372 llvm-svn: 333416 --- llvm/lib/CodeGen/StackColoring.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen/StackColoring.cpp') diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp index 4f3d1f704aa..0bd941e64aa 100644 --- a/llvm/lib/CodeGen/StackColoring.cpp +++ b/llvm/lib/CodeGen/StackColoring.cpp @@ -782,8 +782,11 @@ void StackColoring::calculateLocalLiveness() { 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 -- cgit v1.2.3