|
| 1 | +;; This test verifies that we assign a deterministic location for merged |
| 2 | +;; instructions when -pick-merged-source-locations is enabled. We use the |
| 3 | +;; simplifycfg pass to test this behaviour since it was a common source of |
| 4 | +;; merged instructions, however we intend this to apply to all users of the |
| 5 | +;; getMergedLocation API. |
| 6 | + |
| 7 | +;; Run simplifycfg and check that only 1 call to bar remains and it's debug |
| 8 | +;; location has a valid line number (lexicographically smallest). |
| 9 | +; RUN: opt %s -passes=simplifycfg -hoist-common-insts -pick-merged-source-locations -S | FileCheck %s --check-prefix=ENABLED |
| 10 | +; ENABLED: call i32 @bar{{.*!dbg !}}[[TAG:[0-9]+]] |
| 11 | +; ENABLED-NOT: call i32 @bar |
| 12 | +; ENABLED: ![[TAG]] = !DILocation(line: 9, column: 16, scope: !9) |
| 13 | + |
| 14 | +;; Run simplifycfg without the pass to ensure that we don't spuriously start |
| 15 | +;; passing the test if simplifycfg behaviour changes. |
| 16 | +; RUN: opt %s -passes=simplifycfg -hoist-common-insts -pick-merged-source-locations=false -S | FileCheck %s --check-prefix=DISABLED |
| 17 | +; DISABLED: call i32 @bar{{.*!dbg !}}[[TAG:[0-9]+]] |
| 18 | +; DISABLED-NOT: call i32 @bar |
| 19 | +; DISABLED: ![[TAG]] = !DILocation(line: 0, scope: !9) |
| 20 | + |
| 21 | +; ModuleID = '../llvm/test/DebugInfo/Inputs/debug-info-merge-call.c' |
| 22 | +source_filename = "../llvm/test/DebugInfo/Inputs/debug-info-merge-call.c" |
| 23 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" |
| 24 | +target triple = "x86_64-unknown-linux-gnu" |
| 25 | + |
| 26 | +; Function Attrs: nounwind uwtable |
| 27 | +define dso_local i32 @test(i32 %n) !dbg !9 { |
| 28 | +entry: |
| 29 | + %call = call i32 @foo(i32 %n), !dbg !12 |
| 30 | + %cmp1 = icmp sgt i32 %n, 100, !dbg !13 |
| 31 | + br i1 %cmp1, label %if.then, label %if.else, !dbg !13 |
| 32 | + |
| 33 | +if.then: ; preds = %entry |
| 34 | + %call2 = call i32 @bar(i32 %n), !dbg !14 |
| 35 | + %add = add nsw i32 %call2, %call, !dbg !15 |
| 36 | + br label %if.end, !dbg !16 |
| 37 | + |
| 38 | +if.else: ; preds = %entry |
| 39 | + %call4 = call i32 @bar(i32 %n), !dbg !17 |
| 40 | + br label %if.end |
| 41 | + |
| 42 | +if.end: ; preds = %if.else, %if.then |
| 43 | + %r.0 = phi i32 [ %add, %if.then ], [ %call4, %if.else ], !dbg !18 |
| 44 | + ret i32 %r.0, !dbg !19 |
| 45 | +} |
| 46 | + |
| 47 | +declare !dbg !20 i32 @foo(i32) |
| 48 | + |
| 49 | +declare !dbg !21 i32 @bar(i32) |
| 50 | + |
| 51 | +!llvm.dbg.cu = !{!0} |
| 52 | +!llvm.module.flags = !{!2, !3, !4, !5, !6, !7} |
| 53 | +!llvm.ident = !{!8} |
| 54 | + |
| 55 | +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 21.0.0git ([email protected]:snehasish/llvm-project.git 6ce41db6b0275d060d6e60f88b96a1657024345c)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None) |
| 56 | +!1 = !DIFile(filename: "../llvm/test/DebugInfo/Inputs/debug-info-merge-call.c", directory: "/usr/local/google/home/snehasishk/working/llvm-project/build-assert", checksumkind: CSK_MD5, checksum: "ac1be6c40dad11691922d600f9d55c55") |
| 57 | +!2 = !{i32 7, !"Dwarf Version", i32 5} |
| 58 | +!3 = !{i32 2, !"Debug Info Version", i32 3} |
| 59 | +!4 = !{i32 1, !"wchar_size", i32 4} |
| 60 | +!5 = !{i32 8, !"PIC Level", i32 2} |
| 61 | +!6 = !{i32 7, !"PIE Level", i32 2} |
| 62 | +!7 = !{i32 7, !"uwtable", i32 2} |
| 63 | +!8 = !{! "clang version 21.0.0git ([email protected]:snehasish/llvm-project.git 6ce41db6b0275d060d6e60f88b96a1657024345c)"} |
| 64 | +!9 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 5, type: !10, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 65 | +!10 = !DISubroutineType(types: !11) |
| 66 | +!11 = !{} |
| 67 | +!12 = !DILocation(line: 7, column: 13, scope: !9) |
| 68 | +!13 = !DILocation(line: 8, column: 8, scope: !9) |
| 69 | +!14 = !DILocation(line: 9, column: 16, scope: !9) |
| 70 | +!15 = !DILocation(line: 9, column: 14, scope: !9) |
| 71 | +!16 = !DILocation(line: 10, column: 3, scope: !9) |
| 72 | +!17 = !DILocation(line: 11, column: 10, scope: !9) |
| 73 | +!18 = !DILocation(line: 0, scope: !9) |
| 74 | +!19 = !DILocation(line: 13, column: 3, scope: !9) |
| 75 | +!20 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) |
| 76 | +!21 = !DISubprogram(name: "bar", scope: !1, file: !1, line: 1, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) |
| 77 | + |
0 commit comments