diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -1412,9 +1412,9 @@ const Value *V = DI->getValue(); assert(DI->getVariable()->isValidLocationForIntrinsic(DbgLoc) && "Expected inlined-at fields to agree"); - if (!V) { + if (!V || isa(V)) { // Currently the optimizer can produce this; insert an undef to - // help debugging. Probably the optimizer should not do this. + // help debugging. BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, false, 0U, DI->getVariable(), DI->getExpression()); } else if (const auto *CI = dyn_cast(V)) { @@ -1442,8 +1442,7 @@ BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, IsIndirect, Reg, DI->getVariable(), DI->getExpression()); } else { - // We can't yet handle anything else here because it would require - // generating code, thus altering codegen because of debug info. + // We don't know how to handle other cases, so we drop. LLVM_DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); } return true; diff --git a/llvm/test/CodeGen/AArch64/fastisel-debugvalue-undef.ll b/llvm/test/CodeGen/AArch64/fastisel-debugvalue-undef.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/fastisel-debugvalue-undef.ll @@ -0,0 +1,66 @@ +; RUN: llc -O0 -fast-isel=1 -o - -print-after="finalize-isel" %s 2>&1 | FileCheck %s + +; Check that we emit a DBG_VALUE for the `@llvm.dbg.value` which has `undef` has first arg. +; CHECK: DBG_VALUE $noreg, $noreg, !"MyStruct", !DIExpression(), debug-location + +target triple = "arm64-apple-ios13.4.0" +%T1a8PatatinoC = type <{ %swift.refcounted, %TSi }> +%swift.refcounted = type { %swift.type*, i64 } +%TSi = type <{ i64 }> +%swift.type = type { i64 } +%swift.metadata_response = type { %swift.type*, i64 } +%T1a5TinkyV = type opaque +declare hidden swiftcc %T1a8PatatinoC* @"$s1a8PatatinoCyACSicfC"(i64, %swift.type* swiftself) #0 +declare hidden swiftcc i64 @"$s1a6lambdaySiAA8PatatinoCF"(%T1a8PatatinoC*) #0 +define hidden swiftcc i64 @"$s1a4mainSiyF"() #0 !dbg !37 { +entry: + %LiveObj = alloca %T1a8PatatinoC*, align 8 + %0 = bitcast %T1a8PatatinoC** %LiveObj to i8* + %Ret = alloca %TSi, align 8 + %1 = bitcast %TSi* %Ret to i8* + %2 = bitcast %T1a8PatatinoC** %LiveObj to i8*, !dbg !48 + %3 = call swiftcc %swift.metadata_response @"$s1a8PatatinoCMa"(i64 0) #5, !dbg !51 + %4 = extractvalue %swift.metadata_response %3, 0, !dbg !51 + %5 = call swiftcc %T1a8PatatinoC* @"$s1a8PatatinoCyACSicfC"(i64 37, %swift.type* swiftself %4), !dbg !51 + %6 = bitcast %T1a8PatatinoC* %5 to %swift.refcounted*, !dbg !51 + %7 = call %swift.refcounted* @swift_retain(%swift.refcounted* returned %6) #4, !dbg !51 + %8 = bitcast %TSi* %Ret to i8*, !dbg !48 + %9 = call swiftcc i64 @"$s1a6lambdaySiAA8PatatinoCF"(%T1a8PatatinoC* %5), !dbg !52 + call void @llvm.dbg.value(metadata %T1a5TinkyV* undef, metadata !53, metadata !DIExpression()), !dbg !55 + ret i64 %9, !dbg !57 +} +declare void @llvm.dbg.value(metadata, metadata, metadata) #2 +declare hidden swiftcc %swift.metadata_response @"$s1a8PatatinoCMa"(i64) #3 +declare %swift.refcounted* @swift_retain(%swift.refcounted* returned) #4 +!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10} +!llvm.dbg.cu = !{!11} +!0 = !{i32 2, !"SDK Version", [2 x i32] [i32 13, i32 4]} +!1 = !{i32 1, !"Objective-C Version", i32 2} +!2 = !{i32 1, !"Objective-C Image Info Version", i32 0} +!3 = !{i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"} +!4 = !{i32 4, !"Objective-C Garbage Collection", i32 84018944} +!5 = !{i32 1, !"Objective-C Class Properties", i32 64} +!6 = !{i32 2, !"Dwarf Version", i32 4} +!7 = !{i32 2, !"Debug Info Version", i32 3} +!8 = !{i32 1, !"wchar_size", i32 4} +!9 = !{i32 7, !"PIC Level", i32 2} +!10 = !{i32 1, !"Swift Version", i32 7} +!11 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !12, producer: "Swift version 5.2-dev (Swift f5c0fc7bbf)", isOptimized: false, runtimeVersion: 5, emissionKind: FullDebug, enums: !13, imports: !14) +!12 = !DIFile(filename: "/Users/local/lldb-swift-device/llvm-project/lldb/packages/Python/lldbsuite/test/lang/swift/swift_reference_counting/main.swift", directory: "/Users/local/lldb-swift-device/build/Ninja-ReleaseAssert+stdlib-Release/lldb-macosx-x86_64/bin") +!13 = !{} +!14 = !{} +!37 = distinct !DISubprogram(name: "main", linkageName: "$s1a4mainSiyF", file: !12, line: 26, type: !38, scopeLine: 26, spFlags: DISPFlagDefinition, unit: !11, retainedNodes: !13) +!38 = !DISubroutineType(types: !39) +!39 = !{!40} +!40 = !DICompositeType(tag: DW_TAG_structure_type, name: "Int", file: !41, size: 64, elements: !13, runtimeLang: DW_LANG_Swift, identifier: "$sSiD") +!41 = !DIFile(filename: "tino", directory: "/Users/local/lldb-swift-device/build") +!43 = distinct !DILexicalBlock(scope: !37, file: !12, line: 26, column: 20) +!48 = !DILocation(line: 0, scope: !49) +!49 = !DILexicalBlockFile(scope: !43, file: !50, discriminator: 0) +!50 = !DIFile(filename: "", directory: "") +!51 = !DILocation(line: 27, column: 17, scope: !43) +!52 = !DILocation(line: 28, column: 19, scope: !43) +!53 = !DILocalVariable(name: "MyStruct", scope: !43, file: !12, line: 29, type: !54) +!54 = !DICompositeType(tag: DW_TAG_structure_type, name: "Tinky", file: !12, line: 20, elements: !13, runtimeLang: DW_LANG_Swift, identifier: "$s1a5TinkyVD") +!55 = !DILocation(line: 29, column: 7, scope: !43) +!57 = !DILocation(line: 30, column: 3, scope: !43)