78 lines · plain
1;; This test verifies that we assign a deterministic location for merged2;; instructions when -pick-merged-source-locations is enabled. We use the3;; simplifycfg pass to test this behaviour since it was a common source of4;; merged instructions, however we intend this to apply to all users of the5;; getMergedLocation API.6 7;; Run simplifycfg and check that only 1 call to bar remains and it's debug8;; 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=ENABLED10; ENABLED: call i32 @bar{{.*!dbg !}}[[TAG:[0-9]+]]11; ENABLED-NOT: call i32 @bar12; ENABLED: ![[TAG]] = !DILocation(line: 9, column: 16, scope: !9)13 14;; Run simplifycfg without the pass to ensure that we don't spuriously start15;; 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=DISABLED17; DISABLED: call i32 @bar{{.*!dbg !}}[[TAG:[0-9]+]]18; DISABLED-NOT: call i32 @bar19; DISABLED: ![[TAG]] = !DILocation(line: 0, scope: !9)20 21; ModuleID = '../llvm/test/DebugInfo/Inputs/debug-info-merge-call.c'22source_filename = "../llvm/test/DebugInfo/Inputs/debug-info-merge-call.c"23target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"24target triple = "x86_64-unknown-linux-gnu"25 26; Function Attrs: nounwind uwtable27define dso_local i32 @test(i32 %n) !dbg !9 {28entry:29 %call = call i32 @foo(i32 %n), !dbg !1230 %cmp1 = icmp sgt i32 %n, 100, !dbg !1331 br i1 %cmp1, label %if.then, label %if.else, !dbg !1332 33if.then: ; preds = %entry34 %call2 = call i32 @bar(i32 %n), !dbg !1435 %add = add nsw i32 %call2, %call, !dbg !1536 br label %if.end, !dbg !1637 38if.else: ; preds = %entry39 %call4 = call i32 @bar(i32 %n), !dbg !1740 br label %if.end41 42if.end: ; preds = %if.else, %if.then43 %r.0 = phi i32 [ %add, %if.then ], [ %call4, %if.else ], !dbg !1844 ret i32 %r.0, !dbg !1945}46 47declare !dbg !20 i32 @foo(i32)48 49declare !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 (git@github.com: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 (git@github.com: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 78