|
1 | | -; RUN: opt %s -passes=simplifycfg -hoist-common-insts -preserve-merged-debug-info -S | FileCheck %s |
2 | | -; CHECK: tail call i32 @bar{{.*!dbg !}}[[TAG:[0-9]+]] |
3 | | -; CHECK: ![[TAG]] = !DILocation(line: 9, column: 16, scope: !9) |
| 1 | +;; This test verifies that we assign a deterministic location for merged |
| 2 | +;; instructions when -preserve-merged-debug-info 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 -preserve-merged-debug-info -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 -preserve-merged-debug-info=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) |
4 | 20 |
|
5 | 21 | ; ModuleID = '../llvm/test/DebugInfo/Inputs/debug-info-merge-call.c' |
6 | 22 | source_filename = "../llvm/test/DebugInfo/Inputs/debug-info-merge-call.c" |
7 | 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" |
8 | 24 | target triple = "x86_64-unknown-linux-gnu" |
9 | 25 |
|
10 | 26 | ; Function Attrs: nounwind uwtable |
11 | | -define dso_local i32 @test(i32 noundef %n) local_unnamed_addr #0 !dbg !9 { |
| 27 | +define dso_local i32 @test(i32 %n) !dbg !9 { |
12 | 28 | entry: |
13 | | - %call = tail call i32 @foo(i32 noundef %n) #2, !dbg !12 |
| 29 | + %call = call i32 @foo(i32 %n), !dbg !12 |
14 | 30 | %cmp1 = icmp sgt i32 %n, 100, !dbg !13 |
15 | 31 | br i1 %cmp1, label %if.then, label %if.else, !dbg !13 |
16 | 32 |
|
17 | 33 | if.then: ; preds = %entry |
18 | | - %call2 = tail call i32 @bar(i32 noundef %n) #2, !dbg !14 |
| 34 | + %call2 = call i32 @bar(i32 %n), !dbg !14 |
19 | 35 | %add = add nsw i32 %call2, %call, !dbg !15 |
20 | 36 | br label %if.end, !dbg !16 |
21 | 37 |
|
22 | 38 | if.else: ; preds = %entry |
23 | | - %call4 = tail call i32 @bar(i32 noundef %n) #2, !dbg !17 |
| 39 | + %call4 = call i32 @bar(i32 %n), !dbg !17 |
24 | 40 | br label %if.end |
25 | 41 |
|
26 | 42 | if.end: ; preds = %if.else, %if.then |
27 | 43 | %r.0 = phi i32 [ %add, %if.then ], [ %call4, %if.else ], !dbg !18 |
28 | 44 | ret i32 %r.0, !dbg !19 |
29 | 45 | } |
30 | 46 |
|
31 | | -declare !dbg !20 i32 @foo(i32 noundef) local_unnamed_addr #1 |
32 | | - |
33 | | -declare !dbg !21 i32 @bar(i32 noundef) local_unnamed_addr #1 |
| 47 | +declare !dbg !20 i32 @foo(i32) |
34 | 48 |
|
35 | | -attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } |
36 | | -attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } |
37 | | -attributes #2 = { nounwind } |
| 49 | +declare !dbg !21 i32 @bar(i32) |
38 | 50 |
|
39 | 51 | !llvm.dbg.cu = !{!0} |
40 | 52 | !llvm.module.flags = !{!2, !3, !4, !5, !6, !7} |
|
0 commit comments