xref: /llvm-project/llvm/test/CodeGen/X86/dwarf-eh-prepare-dbg.ll (revision 9bd32d78a9c8c51929f200ceefe735dc687ab10d)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -mtriple=x86_64-linux-gnu -dwarf-eh-prepare < %s | FileCheck %s
3; RUN: opt -S -mtriple=x86_64-linux-gnu -passes=dwarf-eh-prepare < %s | FileCheck %s
4
5; PR57469: If _Unwind_Resume is defined in the same module and we have debug
6; info, then the inserted _Unwind_Resume calls also need to have a dummy debug
7; location to satisfy inlining requirements.
8
9define void @_Unwind_Resume(ptr %ptr) !dbg !4 {
10; CHECK-LABEL: @_Unwind_Resume(
11; CHECK-NEXT:    ret void, !dbg [[DBG11:![0-9]+]]
12;
13  ret void, !dbg !11
14}
15
16declare i32 @__gxx_personality_v0(...)
17declare void @might_throw()
18
19define void @simple_cleanup_catch() personality ptr @__gxx_personality_v0 !dbg !12 {
20; CHECK-LABEL: @simple_cleanup_catch(
21; CHECK-NEXT:    invoke void @might_throw()
22; CHECK-NEXT:    to label [[EXIT:%.*]] unwind label [[LANDINGPAD:%.*]], !dbg [[DBG15:![0-9]+]]
23; CHECK:       exit:
24; CHECK-NEXT:    ret void
25; CHECK:       landingpad:
26; CHECK-NEXT:    [[EX:%.*]] = landingpad { ptr, i32 }
27; CHECK-NEXT:    cleanup
28; CHECK-NEXT:    [[EXN_OBJ:%.*]] = extractvalue { ptr, i32 } [[EX]], 0
29; CHECK-NEXT:    call void @_Unwind_Resume(ptr [[EXN_OBJ]]) #[[ATTR0:[0-9]+]], !dbg [[DBG16:![0-9]+]]
30; CHECK-NEXT:    unreachable
31;
32  invoke void @might_throw()
33  to label %exit unwind label %landingpad, !dbg !15
34
35exit:
36  ret void
37
38landingpad:
39  %ex = landingpad { ptr, i32 }
40  cleanup
41  resume { ptr, i32 } %ex
42}
43
44!llvm.dbg.cu = !{!0}
45!llvm.module.flags = !{!2, !3}
46
47!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 16.0.0 (https://github.com/llvm/llvm-project.git a4c8fb9d1f46f30c66a9ca0dd07c7933f338bb34)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
48!1 = !DIFile(filename: "/app/example.c", directory: "/app")
49!2 = !{i32 7, !"Dwarf Version", i32 4}
50!3 = !{i32 2, !"Debug Info Version", i32 3}
51!4 = distinct !DISubprogram(name: "_Unwind_Resume", scope: !5, file: !5, line: 1, type: !6, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !9)
52!5 = !DIFile(filename: "example.c", directory: "/app")
53!6 = !DISubroutineType(types: !7)
54!7 = !{null, !8}
55!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
56!9 = !{!10}
57!10 = !DILocalVariable(name: "exception", arg: 1, scope: !4, file: !5, line: 1, type: !8)
58!11 = !DILocation(line: 2, column: 1, scope: !4)
59!12 = distinct !DISubprogram(name: "test", scope: !5, file: !5, line: 4, type: !13, scopeLine: 4, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
60!13 = !DISubroutineType(types: !14)
61!14 = !{null}
62!15 = !DILocation(line: 6, column: 1, scope: !12)
63
64; CHECK: [[DBG_SCOPE:![0-9]+]] = distinct !DISubprogram(name: "test"
65; CHECK: [[DBG16]] = !DILocation(line: 0, scope: [[DBG_SCOPE]])
66