[HotColdSplit] Relax requirement that the cold sink block be extractable

Relaxing this requirement creates opportunities to split code dominated
by an EH pad.

Tested on LNT+externals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351483 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/IPO/HotColdSplitting.cpp b/lib/Transforms/IPO/HotColdSplitting.cpp
index d0f3fdf..2cf8af3 100644
--- a/lib/Transforms/IPO/HotColdSplitting.cpp
+++ b/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -391,7 +391,8 @@
 
     // Add SinkBB to the cold region. It's considered as an entry point before
     // any sink-successor blocks.
-    addBlockToRegion(&SinkBB, SinkScore);
+    if (mayExtractBlock(SinkBB))
+      addBlockToRegion(&SinkBB, SinkScore);
 
     // Find all successors of SinkBB dominated by SinkBB using DFS.
     auto SuccIt = ++df_begin(&SinkBB);
@@ -486,10 +487,6 @@
 
   // Find all cold regions.
   for (BasicBlock *BB : RPOT) {
-    // Skip blocks which can't be outlined.
-    if (!mayExtractBlock(*BB))
-      continue;
-
     // This block is already part of some outlining region.
     if (ColdBlocks.count(BB))
       continue;
diff --git a/test/Transforms/HotColdSplit/eh-pads.ll b/test/Transforms/HotColdSplit/eh-pads.ll
index caf02e9..979d005 100644
--- a/test/Transforms/HotColdSplit/eh-pads.ll
+++ b/test/Transforms/HotColdSplit/eh-pads.ll
@@ -58,6 +58,9 @@
 ; CHECK: sideeffect(i32 0)
 ; CHECK: sink
 
+; CHECK-LABEL: define {{.*}}@bar.cold.1(
+; CHECK: sideeffect(i32 1)
+
 declare void @sideeffect(i32)
 
 declare void @sink() cold