62 lines · plain
1; REQUIRES: x86-registered-target2; RUN: llc -start-before=codegenprepare -stop-after=codegenprepare \3; RUN: -mtriple=x86_64-unknown-unknown %s -o - \4; RUN: | FileCheck %s --implicit-check-not="#dbg_"5 6;; Check that when CodeGenPrepare moves an address computation to a block it's7;; used in its dbg.assign uses are updated.8;;9;; Based on llvm/test/DebugInfo/X86/codegenprepare-addrsink.ll10 11define dso_local i8 @foo(ptr %p, i32 %cond) !dbg !7 {12entry:13 %casted = bitcast ptr %p to ptr14 %arith = getelementptr i8, ptr %casted, i32 315 %load1 = load i8, ptr %arith16 %cmpresult = icmp eq i32 %cond, 017 br i1 %cmpresult, label %next, label %ret18 19next:20; Address calcs should be duplicated into this block. One dbg.value should be21; updated, and the other should not.22; CHECK-LABEL: next:23; CHECK: %[[CASTVAR:[0-9a-zA-Z]+]] = bitcast ptr %p to ptr24; CHECK-NEXT: #dbg_assign(ptr %arith, ![[DIVAR:[0-9]+]],25; CHECK-NEXT: %[[GEPVAR:[0-9a-zA-Z]+]] = getelementptr i8, ptr %[[CASTVAR]], i64 326; CHECK-NEXT: %loaded = load i8, ptr %[[GEPVAR]]27; CHECK-NEXT: #dbg_assign(ptr %[[GEPVAR]], ![[DIVAR]],28 call void @llvm.dbg.assign(metadata ptr %arith, metadata !12, metadata !DIExpression(), metadata !21, metadata ptr undef, metadata !DIExpression()), !dbg !1429 %loaded = load i8, ptr %arith30 call void @llvm.dbg.assign(metadata ptr %arith, metadata !12, metadata !DIExpression(), metadata !21, metadata ptr undef, metadata !DIExpression()), !dbg !1431 ret i8 %loaded32 33ret:34 ret i8 035}36 37; CHECK: ![[DIVAR]] = !DILocalVariable(name: "p",38 39declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)40 41!llvm.dbg.cu = !{!0}42!llvm.module.flags = !{!3, !4, !5, !1000}43!llvm.ident = !{!6}44 45!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)46!1 = !DIFile(filename: "test.cpp", directory: ".")47!2 = !{}48!3 = !{i32 2, !"Dwarf Version", i32 4}49!4 = !{i32 2, !"Debug Info Version", i32 3}50!5 = !{i32 1, !"wchar_size", i32 4}51!6 = !{!"clang version 8.0.0 (trunk 348209)"}52!7 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 4, type: !8, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)53!8 = !DISubroutineType(types: !9)54!9 = !{null, !10}55!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)56!11 = !{!12}57!12 = !DILocalVariable(name: "p", arg: 1, scope: !7, file: !1, line: 4, type: !10)58!14 = !DILocation(line: 4, column: 15, scope: !7)59!20 = distinct !DILexicalBlock(scope: !7, file: !1, line: 8, column: 7)60!21 = distinct !DIAssignID()61!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}62