Update getMergedLocation to check the instruction type and merge properly.
Summary: If the merged instruction is call instruction, we need to set the scope to the closes common scope between 2 locations, otherwise it will cause trouble when the call is getting inlined.
Reviewers: dblaikie, aprantl
Reviewed By: dblaikie, aprantl
Subscribers: llvm-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D37877
llvm-svn: 314694
diff --git a/llvm/test/Transforms/SimplifyCFG/remove-debug.ll b/llvm/test/Transforms/SimplifyCFG/remove-debug.ll
index d4b2373..dcc03bd 100644
--- a/llvm/test/Transforms/SimplifyCFG/remove-debug.ll
+++ b/llvm/test/Transforms/SimplifyCFG/remove-debug.ll
@@ -2,14 +2,9 @@
; TODO: Track the acutal DebugLoc of the hoisted instruction when no-line
; DebugLoc is supported (https://reviews.llvm.org/D24180)
-; CHECK: line: 6
-; CHECK-NOT: line: 7
-; CHECK: line: 8
-; CHECK: line: 9
-; CHECK-NOT: line: 10
-; CHECK: line: 11
-; Checks if the debug info for hoisted "x = i" is removed
+; Checks if the debug info for hoisted "x = i" is removed and
+; the debug info for hoisted "bar()" is set as line 0
; int x;
; void bar();
; void baz();
@@ -20,6 +15,7 @@
; bar();
; } else {
; x = i;
+; bar();
; baz();
; }
; }
@@ -30,6 +26,10 @@
; Function Attrs: uwtable
define void @_Z3fooi(i32) #0 !dbg !6 {
+; CHECK: load i32, i32* %2, align 4, !tbaa
+; CHECK: store i32 %5, i32* @x, align 4, !tbaa
+; CHECK: call void @_Z3barv(), !dbg ![[BAR:[0-9]+]]
+; CHECK: call void @_Z3bazv(), !dbg ![[BAZ:[0-9]+]]
%2 = alloca i32, align 4
store i32 %0, i32* %2, align 4, !tbaa !8
%3 = load i32, i32* %2, align 4, !dbg !12, !tbaa !8
@@ -45,7 +45,8 @@
; <label>:7:
%8 = load i32, i32* %2, align 4, !dbg !18, !tbaa !8
store i32 %8, i32* @x, align 4, !dbg !19, !tbaa !8
- call void @_Z3bazv(), !dbg !20
+ call void @_Z3barv(), !dbg !20
+ call void @_Z3bazv(), !dbg !21
br label %9
; <label>:9:
@@ -59,6 +60,8 @@
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4}
+; CHECK: ![[BAR]] = !DILocation(line: 0
+; CHECK: ![[BAZ]] = !DILocation(line: 12, column: 5
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
!1 = !DIFile(filename: "a", directory: "b/")
!2 = !{}
@@ -80,4 +83,5 @@
!18 = !DILocation(line: 10, column: 9, scope: !6)
!19 = !DILocation(line: 10, column: 7, scope: !6)
!20 = !DILocation(line: 11, column: 5, scope: !6)
-!21 = !DILocation(line: 13, column: 1, scope: !6)
+!21 = !DILocation(line: 12, column: 5, scope: !6)
+!22 = !DILocation(line: 14, column: 1, scope: !6)