Skip to content

Commit 9e90c02

Browse files
alexey-bataevIanWood1
authored andcommitted
[SLP]Check for catchswitch block before doing the analysis of the instructions
Need to skip the analysis of the catchswitch blocks to avoid a compiler crash when trying to get the first instruction in the block.
1 parent 7bd1306 commit 9e90c02

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14133,7 +14133,8 @@ InstructionCost BoUpSLP::getSpillCost() {
1413314133
Budget += BlockSize;
1413414134
if (Budget > BudgetLimit)
1413514135
return Res;
14136-
if (!CheckForNonVecCallsInSameBlock(&*BB->getFirstNonPHIOrDbgOrAlloca(),
14136+
if (!isa<CatchSwitchInst>(BB->getTerminator()) &&
14137+
!CheckForNonVecCallsInSameBlock(&*BB->getFirstNonPHIOrDbgOrAlloca(),
1413714138
BB->getTerminator()))
1413814139
return Res;
1413914140
Worklist.append(pred_begin(BB), pred_end(BB));
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-pc-windows-msvc19.40.33811 < %s | FileCheck %s
3+
4+
%"class.boost::execution_exception" = type { i32, %"class.boost::unit_test::basic_cstring", %"struct.boost::execution_exception::location" }
5+
%"class.boost::unit_test::basic_cstring" = type { ptr, ptr }
6+
%"struct.boost::execution_exception::location" = type { %"class.boost::unit_test::basic_cstring", i64, %"class.boost::unit_test::basic_cstring" }
7+
8+
define void @test() personality ptr null {
9+
; CHECK-LABEL: define void @test() personality ptr null {
10+
; CHECK-NEXT: [[ENTRY:.*]]:
11+
; CHECK-NEXT: br label %[[FOR_COND109:.*]]
12+
; CHECK: [[FOR_COND109]]:
13+
; CHECK-NEXT: [[TMP0:%.*]] = phi <2 x ptr> [ zeroinitializer, %[[ENTRY]] ], [ zeroinitializer, %[[IF_END153:.*]] ]
14+
; CHECK-NEXT: br label %[[INIT_ATTEMPT_I664:.*]]
15+
; CHECK: [[INIT_ATTEMPT_I664]]:
16+
; CHECK-NEXT: [[CALL_I666:%.*]] = invoke ptr null(ptr null)
17+
; CHECK-NEXT: to label %[[INVOKE_CONT_I668:.*]] unwind label %[[CATCH_DISPATCH:.*]]
18+
; CHECK: [[INVOKE_CONT_I668]]:
19+
; CHECK-NEXT: ret void
20+
; CHECK: [[CATCH_DISPATCH]]:
21+
; CHECK-NEXT: [[TMP1:%.*]] = catchswitch within none [label %catch] unwind to caller
22+
; CHECK: [[CATCH:.*]]:
23+
; CHECK-NEXT: [[TMP2:%.*]] = catchpad within [[TMP1]] [ptr null, i32 0, ptr null]
24+
; CHECK-NEXT: br i1 false, label %[[IF_END153]], label %[[INVOKE_CONT149:.*]]
25+
; CHECK: [[INVOKE_CONT149]]:
26+
; CHECK-NEXT: [[TMP3:%.*]] = load <2 x ptr>, ptr null, align 8
27+
; CHECK-NEXT: br label %[[IF_END153]]
28+
; CHECK: [[IF_END153]]:
29+
; CHECK-NEXT: [[TMP4:%.*]] = phi <2 x ptr> [ [[TMP0]], %[[CATCH]] ], [ [[TMP3]], %[[INVOKE_CONT149]] ]
30+
; CHECK-NEXT: catchret from [[TMP2]] to label %[[FOR_COND109]]
31+
;
32+
entry:
33+
br label %for.cond109
34+
35+
for.cond109:
36+
%setup_error.sroa.0.1 = phi ptr [ null, %entry ], [ null, %if.end153 ]
37+
%setup_error.sroa.6.1 = phi ptr [ null, %entry ], [ null, %if.end153 ]
38+
br label %init.attempt.i664
39+
40+
init.attempt.i664:
41+
%call.i666 = invoke ptr null(ptr null)
42+
to label %invoke.cont.i668 unwind label %catch.dispatch
43+
44+
invoke.cont.i668:
45+
ret void
46+
47+
catch.dispatch:
48+
%0 = catchswitch within none [label %catch] unwind to caller
49+
50+
catch:
51+
%1 = catchpad within %0 [ptr null, i32 0, ptr null]
52+
br i1 false, label %if.end153, label %invoke.cont149
53+
54+
invoke.cont149:
55+
%m_begin2.i.i = getelementptr %"class.boost::execution_exception", ptr null, i64 0, i32 1, i32 0
56+
%2 = load ptr, ptr %m_begin2.i.i, align 8
57+
%3 = load ptr, ptr null, align 8
58+
br label %if.end153
59+
60+
if.end153:
61+
%setup_error.sroa.0.2 = phi ptr [ %setup_error.sroa.0.1, %catch ], [ %2, %invoke.cont149 ]
62+
%setup_error.sroa.6.2 = phi ptr [ %setup_error.sroa.6.1, %catch ], [ %3, %invoke.cont149 ]
63+
catchret from %1 to label %for.cond109
64+
}

0 commit comments

Comments
 (0)