Skip to content

Commit a2dba0c

Browse files
authored
[SEH][CodeGen] Add test to track CFG optimization bug for SEH (#77441)
LiveDebugValues requires CFG only has one entry. BranchFolding and MachineBlockPlacement may remove all predecessors of landing pad which leaves it to be another entry.
1 parent 2d54ec3 commit a2dba0c

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
; XFAIL: *
2+
; RUN: llc -mtriple=x86_64-pc-windows-msvc %s
3+
define dso_local void @main(ptr %addr, ptr %src, ptr %dst) personality ptr @__CxxFrameHandler3 !dbg !11 {
4+
entry:
5+
%tmp0 = load float, ptr %src
6+
%src1 = getelementptr inbounds float, ptr %src, i64 1
7+
%tmp1 = load float, ptr %src1
8+
%src2 = getelementptr inbounds float, ptr %src, i64 2
9+
%tmp2 = load float, ptr %src2
10+
%src3 = getelementptr inbounds float, ptr %src, i64 3
11+
%tmp3 = load float, ptr %src3
12+
%src4 = getelementptr inbounds float, ptr %src, i64 4
13+
%tmp4 = load float, ptr %src4
14+
%src5 = getelementptr inbounds float, ptr %src, i64 5
15+
%tmp5 = load float, ptr %src5
16+
%src6 = getelementptr inbounds float, ptr %src, i64 6
17+
%tmp6 = load float, ptr %src6
18+
invoke void @foo(ptr %addr)
19+
to label %scope_begin unwind label %ehcleanup1, !dbg !13
20+
21+
scope_begin:
22+
invoke void @llvm.seh.scope.begin()
23+
to label %scope_end unwind label %ehcleanup, !dbg !13
24+
25+
scope_end:
26+
invoke void @llvm.seh.scope.end()
27+
to label %finish unwind label %ehcleanup, !dbg !13
28+
29+
ehcleanup:
30+
%0 = cleanuppad within none [], !dbg !13
31+
call void @llvm.dbg.value(metadata ptr %addr, metadata !12, metadata !DIExpression()), !dbg !13
32+
call void @foo(ptr %addr) [ "funclet"(token %0) ], !dbg !13
33+
cleanupret from %0 unwind label %ehcleanup1, !dbg !13
34+
35+
ehcleanup1:
36+
%1 = cleanuppad within none [], !dbg !13
37+
call void @foo(ptr %addr) [ "funclet"(token %1) ], !dbg !13
38+
cleanupret from %1 unwind to caller, !dbg !13
39+
40+
finish:
41+
store float %tmp0, ptr %dst
42+
%dst1 = getelementptr inbounds float, ptr %dst, i64 1
43+
store float %tmp1, ptr %dst1
44+
%dst2 = getelementptr inbounds float, ptr %dst, i64 2
45+
store float %tmp2, ptr %dst2
46+
%dst3 = getelementptr inbounds float, ptr %dst, i64 3
47+
store float %tmp3, ptr %dst3
48+
%dst4 = getelementptr inbounds float, ptr %dst, i64 4
49+
store float %tmp4, ptr %dst4
50+
%dst5 = getelementptr inbounds float, ptr %dst, i64 5
51+
store float %tmp5, ptr %dst5
52+
%dst6 = getelementptr inbounds float, ptr %dst, i64 6
53+
store float %tmp6, ptr %dst6
54+
ret void
55+
}
56+
57+
declare dso_local void @llvm.seh.scope.begin()
58+
declare dso_local void @llvm.seh.scope.end()
59+
declare dso_local i32 @__CxxFrameHandler3(...)
60+
declare dso_local void @foo(ptr %addr)
61+
declare void @llvm.dbg.value(metadata, metadata, metadata)
62+
63+
!llvm.module.flags = !{!0, !1, !2, !3}
64+
!llvm.dbg.cu = !{!14}
65+
66+
!0 = !{i32 2, !"eh-asynch", i32 1}
67+
!1 = !{i32 2, !"CodeView", i32 1}
68+
!2 = !{i32 2, !"Debug Info Version", i32 3}
69+
!3 = !{i32 7, !"uwtable", i32 2}
70+
71+
!4 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
72+
!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64)
73+
!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
74+
!7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)
75+
!8 = !DISubroutineType(types: !9)
76+
!9 = !{null, !7, !5, !5}
77+
!10 = !DIFile(filename: "c:/main.cpp", directory: "")
78+
!11 = distinct !DISubprogram(name: "main", scope: !10, file: !10, line: 5, type: !8, scopeLine: 11, unit: !14)
79+
!12 = !DILocalVariable(name: "addr", scope: !11, file: !10, line: 5, type: !7)
80+
!13 = !DILocation(line: 7, scope: !11)
81+
!14 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !10, isOptimized: true, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)

0 commit comments

Comments
 (0)