1; RUN: llc %s -stop-before=finalize-isel -o -\ 2; RUN: -experimental-debug-variable-locations \ 3; RUN: | FileCheck %s 4; 5; Test that instruction referencing variable locations can cope with exception 6; landing pads. Variable locations can be derived from the ABI-defined arguments 7; to landing-pad blocks, which should be treated much like argument locations. 8; This gloriously simple piece of C++: 9; 10; void a() try { a(); } catch (int *&) { } 11; 12; Produces the code below. A nameless variable is attached to the landing-pad 13; record %0 (via %3), which salvages back to the entry to the landing pad. We 14; should place a DBG_PHI at that point. Instead of crashing. 15; 16; CHECK-LABEL: bb.1.lpad (landing-pad): 17; CHECK: DBG_PHI $rax, 1 18; CHECK-NEXT: EH_LABEL 19 20target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 21target triple = "x86_64-unknown-linux-gnu" 22 23@_ZTIPi = external dso_local constant ptr 24 25define dso_local void @_Z1av() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 !dbg !8 { 26entry: 27 invoke void @_Z1av() 28 to label %try.cont unwind label %lpad, !dbg !17 29 30lpad: ; preds = %entry 31 %0 = landingpad { ptr, i32 } 32 catch ptr @_ZTIPi, !dbg !19 33 %1 = extractvalue { ptr, i32 } %0, 1, !dbg !19 34 %2 = tail call i32 @llvm.eh.typeid.for(ptr @_ZTIPi) #3, !dbg !20 35 %matches = icmp eq i32 %1, %2, !dbg !20 36 br i1 %matches, label %catch, label %eh.resume, !dbg !20 37 38catch: ; preds = %lpad 39 %3 = extractvalue { ptr, i32 } %0, 0, !dbg !19 40 %4 = tail call ptr @__cxa_begin_catch(ptr %3) #3, !dbg !20 41 call void @llvm.dbg.value(metadata ptr %3, metadata !13, metadata !DIExpression(DW_OP_plus_uconst, 32, DW_OP_stack_value)), !dbg !21 42 tail call void @__cxa_end_catch() #3, !dbg !22 43 br label %try.cont, !dbg !22 44 45try.cont: ; preds = %entry, %catch 46 ret void, !dbg !24 47 48eh.resume: ; preds = %lpad 49 resume { ptr, i32 } %0, !dbg !20 50} 51 52declare dso_local i32 @__gxx_personality_v0(...) 53 54; Function Attrs: nofree nosync nounwind readnone 55declare i32 @llvm.eh.typeid.for(ptr) #1 56 57declare dso_local ptr @__cxa_begin_catch(ptr) local_unnamed_addr 58 59declare dso_local void @__cxa_end_catch() local_unnamed_addr 60 61; Function Attrs: mustprogress nofree nosync nounwind readnone speculatable willreturn 62declare void @llvm.dbg.value(metadata, metadata, metadata) #2 63 64!llvm.dbg.cu = !{!0} 65!llvm.module.flags = !{!3, !4, !5, !6} 66!llvm.ident = !{!7} 67 68!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 69!1 = !DIFile(filename: "test.cpp", directory: ".") 70!2 = !{} 71!3 = !{i32 7, !"Dwarf Version", i32 4} 72!4 = !{i32 2, !"Debug Info Version", i32 3} 73!5 = !{i32 1, !"wchar_size", i32 4} 74!6 = !{i32 7, !"uwtable", i32 1} 75!7 = !{!"clang"} 76!8 = distinct !DISubprogram(name: "a", linkageName: "_Z1av", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12) 77!9 = !DIFile(filename: "test.cpp", directory: "") 78!10 = !DISubroutineType(types: !11) 79!11 = !{null} 80!12 = !{!13} 81!13 = !DILocalVariable(scope: !8, file: !9, line: 1, type: !14) 82!14 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !15, size: 64) 83!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64) 84!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 85!17 = !DILocation(line: 1, column: 16, scope: !18) 86!18 = distinct !DILexicalBlock(scope: !8, file: !9, line: 1, column: 14) 87!19 = !DILocation(line: 2, column: 1, scope: !18) 88!20 = !DILocation(line: 1, column: 21, scope: !18) 89!21 = !DILocation(line: 0, scope: !8) 90!22 = !DILocation(line: 2, column: 1, scope: !23) 91!23 = distinct !DILexicalBlock(scope: !8, file: !9, line: 1, column: 38) 92!24 = !DILocation(line: 2, column: 1, scope: !8) 93