Skip to content

Commit df04e25

Browse files
author
Snehasish Kumar
committed
Address comments.
1 parent cb23baa commit df04e25

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

llvm/test/DebugInfo/preserve-merged-debug-info.ll

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,52 @@
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)
420

521
; ModuleID = '../llvm/test/DebugInfo/Inputs/debug-info-merge-call.c'
622
source_filename = "../llvm/test/DebugInfo/Inputs/debug-info-merge-call.c"
723
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"
824
target triple = "x86_64-unknown-linux-gnu"
925

1026
; 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 {
1228
entry:
13-
%call = tail call i32 @foo(i32 noundef %n) #2, !dbg !12
29+
%call = call i32 @foo(i32 %n), !dbg !12
1430
%cmp1 = icmp sgt i32 %n, 100, !dbg !13
1531
br i1 %cmp1, label %if.then, label %if.else, !dbg !13
1632

1733
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
1935
%add = add nsw i32 %call2, %call, !dbg !15
2036
br label %if.end, !dbg !16
2137

2238
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
2440
br label %if.end
2541

2642
if.end: ; preds = %if.else, %if.then
2743
%r.0 = phi i32 [ %add, %if.then ], [ %call4, %if.else ], !dbg !18
2844
ret i32 %r.0, !dbg !19
2945
}
3046

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)
3448

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)
3850

3951
!llvm.dbg.cu = !{!0}
4052
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}

0 commit comments

Comments
 (0)