Skip to content

Commit f0010d1

Browse files
R-Goctru
authored andcommitted
[Windows SEH] Fix crash on empty seh block (llvm#107031)
Fixes llvm#105813 and llvm#106915. Adds a check for the end of the iterator, which can be a sentinel. The issue was introduced in llvm@0efe111 from what I can see, so along with the introduction of /EHa support. (cherry picked from commit 2e0ded3)
1 parent 93998af commit f0010d1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,10 @@ void SelectionDAGISel::reportIPToStateForBlocks(MachineFunction *MF) {
14531453
if (BB->getFirstMayFaultInst()) {
14541454
// Report IP range only for blocks with Faulty inst
14551455
auto MBBb = MBB.getFirstNonPHI();
1456+
1457+
if (MBBb == MBB.end())
1458+
continue;
1459+
14561460
MachineInstr *MIb = &*MBBb;
14571461
if (MIb->isTerminator())
14581462
continue;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=x86_64-pc-windows-msvc19.41.34120 < %s | FileCheck %s
3+
4+
define void @foo() personality ptr @__CxxFrameHandler3 {
5+
; CHECK-LABEL: foo:
6+
; CHECK: # %bb.0:
7+
; CHECK-NEXT: nop # avoids zero-length function
8+
call void @llvm.seh.scope.begin()
9+
unreachable
10+
}
11+
12+
declare i32 @__CxxFrameHandler3(...)
13+
14+
declare void @llvm.seh.scope.begin()
15+
16+
!llvm.module.flags = !{!0}
17+
18+
!0 = !{i32 2, !"eh-asynch", i32 1}

0 commit comments

Comments
 (0)