Taewook Oh
9fdcd96d07
Make MachineBasicBlock::updateTerminator to update DebugLoc as well
Summary:
Currently MachineBasicBlock::updateTerminator simply drops DebugLoc for newly created branch instructions, which may cause incorrect stepping and/or imprecise sample profile data. Below is an example:
```
1 extern int bar(int x);
2
3 int foo(int *begin, int *end) {
4 int *i;
5 int ret = 0;
6 for (
7 i = begin ;
8 i != end ;
9 i++)
10 {
11 ret += bar(*i);
12 }
13 return ret;
14 }
```
Below is a bitcode of 'foo' at the end of LLVM-IR level optimizations with -O3:
```
define i32 @foo(i32* readonly %begin, i32* readnone %end) !dbg !4 {
entry:
%cmp6 = icmp eq i32* %begin, %end, !dbg !9
br i1 %cmp6, label %for.end, label %for.body.preheader, !dbg !12
for.body.preheader: ; preds = %entry
br label %for.body, !dbg !13
for.body: ; preds = %for.body.preheader, %for.body
%ret.08 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]
%i.07 = phi i32* [ %incdec.ptr, %for.body ], [ %begin, %for.body.preheader ]
%0 = load i32, i32* %i.07, align 4, !dbg !13, !tbaa !15
%call = tail call i32 @bar(i32 %0), !dbg !19
%add = add nsw i32 %call, %ret.08, !dbg !20
%incdec.ptr = getelementptr inbounds i32, i32* %i.07, i64 1, !dbg !21
%cmp = icmp eq i32* %incdec.ptr, %end, !dbg !9
br i1 %cmp, label %for.end.loopexit, label %for.body, !dbg !12, !llvm.loop !22
for.end.loopexit: ; preds = %for.body
br label %for.end, !dbg !24
for.end: ; preds = %for.end.loopexit, %entry
%ret.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.end.loopexit ]
ret i32 %ret.0.lcssa, !dbg !24
}
```
where
```
!12 = !DILocation(line: 6, column: 3, scope: !11)
```
. As you can see, the terminator of 'entry' block, which is a loop control branch, has a DebugLoc of line 6, column 3. Howerver, after the execution of 'MachineBlock::updateTerminator' function, which is triggered by MachineSinking pass, the DebugLoc info is dropped as below (see there's no debug-location for JNE_1):
```
bb.0.entry:
successors: %bb.4(0x30000000), %bb.1.for.body.preheader(0x50000000)
liveins: %rdi, %rsi
%6 = COPY %rsi
%5 = COPY %rdi
%8 = SUB64rr %5, %6, implicit-def %eflags, debug-location !9
JNE_1 %bb.1.for.body.preheader, implicit %eflags
```
This patch addresses this issue and make newly created branch instructions to keep debug-location info.
Reviewers: aprantl, MatzeB, craig.topper, qcolombet
Reviewed By: qcolombet
Subscribers: qcolombet, llvm-commits
Differential Revision: https://reviews.llvm.org/D29596
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294976 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-13 18:15:31 +00:00
..
2017-02-10 07:05:56 +00:00
2017-01-11 19:55:19 +00:00
2017-02-02 18:24:55 +00:00
2017-02-05 18:33:24 +00:00
2017-02-05 18:33:24 +00:00
2017-02-05 18:33:24 +00:00
2017-02-02 18:24:55 +00:00
2017-02-09 22:02:28 +00:00
2017-02-02 00:32:03 +00:00
2017-01-11 19:55:19 +00:00
2017-02-08 00:32:36 +00:00
2017-02-11 19:27:15 +00:00
2017-01-17 19:18:57 +00:00
2017-02-11 19:34:11 +00:00
2017-02-05 18:33:14 +00:00
2017-01-07 20:38:36 +00:00
2017-02-05 18:33:14 +00:00
2017-01-24 16:53:09 +00:00
2017-02-05 18:33:14 +00:00
2017-02-05 18:33:14 +00:00
2017-01-04 08:05:42 +00:00
2017-01-07 22:20:34 +00:00
2017-01-14 07:50:52 +00:00
2017-01-09 02:44:34 +00:00
2017-01-31 23:48:32 +00:00
2017-01-12 06:49:12 +00:00
2017-01-24 02:36:59 +00:00
2017-02-12 23:49:49 +00:00
2017-01-05 01:34:55 +00:00
2017-02-09 11:50:19 +00:00
2017-02-13 04:53:29 +00:00
2017-01-14 07:50:52 +00:00
2017-01-14 07:50:52 +00:00
2017-01-07 22:20:34 +00:00
2017-01-24 02:36:59 +00:00
2017-01-14 07:50:52 +00:00
2017-01-12 06:49:03 +00:00
2017-02-13 04:53:33 +00:00
2017-01-29 13:18:30 +00:00
2017-01-30 06:59:06 +00:00
2017-01-14 07:50:52 +00:00
2017-01-19 07:12:35 +00:00
2017-01-07 22:20:34 +00:00
2017-01-14 07:50:52 +00:00
2017-02-09 11:50:19 +00:00
2017-01-07 22:20:34 +00:00
2017-01-14 07:50:52 +00:00
2017-01-24 02:36:59 +00:00
2017-01-19 02:34:25 +00:00
2017-01-19 02:34:25 +00:00
2017-02-09 11:50:19 +00:00
2017-01-07 22:20:34 +00:00
2017-01-30 06:59:06 +00:00
2017-01-14 07:50:52 +00:00
2017-02-05 22:50:29 +00:00
2017-01-11 09:11:48 +00:00
2017-02-07 04:10:57 +00:00
2017-01-11 19:55:19 +00:00
2017-01-29 13:18:30 +00:00
2017-01-31 05:18:29 +00:00
2017-02-13 04:53:29 +00:00
2017-02-07 19:19:49 +00:00
2017-01-30 23:37:03 +00:00
2017-01-31 23:48:32 +00:00
2017-02-09 11:50:19 +00:00
2017-01-12 19:48:01 +00:00
2017-01-12 19:54:27 +00:00
2017-01-12 19:54:27 +00:00
2017-02-02 18:24:55 +00:00
2017-01-10 23:43:04 +00:00
2017-02-13 04:53:33 +00:00
2017-02-08 05:45:46 +00:00
2017-02-09 04:27:34 +00:00
2017-01-24 16:36:07 +00:00
2017-01-12 19:54:27 +00:00
2017-02-07 13:15:09 +00:00
2017-02-03 17:59:58 +00:00
2017-02-05 18:33:14 +00:00
2017-02-02 18:24:55 +00:00
2017-02-02 18:24:55 +00:00
2017-02-11 14:01:37 +00:00
2017-02-11 12:23:22 +00:00
2017-02-11 12:29:56 +00:00
2017-02-11 12:30:59 +00:00
2017-02-09 21:58:24 +00:00
2017-02-06 22:42:43 +00:00
2017-02-02 18:24:55 +00:00
2017-02-04 02:27:13 +00:00
2017-01-10 06:01:16 +00:00
2017-01-11 19:55:19 +00:00
2017-02-02 18:24:55 +00:00
2017-02-03 12:28:40 +00:00
2017-01-24 16:36:07 +00:00
2017-02-06 14:54:49 +00:00
2017-02-02 18:24:55 +00:00
2017-01-18 16:58:43 +00:00
2017-01-30 06:59:06 +00:00
2017-02-13 14:20:13 +00:00
2017-01-10 22:02:30 +00:00
2017-02-02 18:24:55 +00:00
2017-02-13 17:38:59 +00:00
2017-01-31 17:00:27 +00:00
2017-01-07 22:20:34 +00:00
2017-01-09 20:26:17 +00:00
2017-02-11 22:47:06 +00:00
2017-01-31 06:49:53 +00:00
2017-01-26 23:27:59 +00:00
2017-01-31 23:48:32 +00:00
2017-01-04 12:08:35 +00:00
2017-01-04 12:08:35 +00:00
2017-01-10 22:02:30 +00:00
2017-01-04 08:05:42 +00:00
2017-02-10 16:34:17 +00:00
2017-02-02 18:24:55 +00:00
2017-02-07 19:19:49 +00:00
2017-02-07 19:19:49 +00:00
2017-01-18 09:31:13 +00:00
2017-02-11 22:57:12 +00:00
2017-01-31 23:48:32 +00:00
2017-01-19 22:41:22 +00:00
2017-02-08 00:32:36 +00:00
2017-02-11 00:50:23 +00:00
2017-02-02 18:24:55 +00:00
2017-02-09 15:13:40 +00:00
2017-01-05 15:11:43 +00:00
2017-02-13 09:57:17 +00:00
2017-01-11 19:55:19 +00:00
2017-01-20 07:12:30 +00:00
2017-01-14 07:50:52 +00:00
2017-02-03 11:14:39 +00:00
2017-02-03 19:11:19 +00:00
2017-02-03 19:11:19 +00:00
2017-02-03 19:11:19 +00:00
2017-02-02 18:24:55 +00:00
2017-02-11 05:32:57 +00:00
2017-01-15 16:43:14 +00:00
2017-02-02 18:24:55 +00:00
2017-02-02 18:24:55 +00:00
2017-02-06 16:21:41 +00:00
2017-02-09 17:54:51 +00:00
2017-02-09 17:54:51 +00:00
2017-01-25 06:08:42 +00:00
2017-01-31 06:49:50 +00:00
2017-02-11 05:32:57 +00:00
2017-02-11 05:32:57 +00:00
2017-02-10 17:57:48 +00:00
2017-01-09 21:38:17 +00:00
2017-01-21 06:59:38 +00:00
2017-01-24 11:46:13 +00:00
2017-02-05 18:33:24 +00:00
2017-01-24 16:56:23 +00:00
2017-02-10 17:57:46 +00:00
2017-02-10 17:26:21 +00:00
2017-01-24 16:58:22 +00:00
2017-02-05 18:33:24 +00:00
2017-02-02 18:24:55 +00:00
2017-02-02 17:23:57 +00:00
2017-02-11 19:27:15 +00:00
2017-02-03 17:59:58 +00:00
2017-02-11 19:27:15 +00:00
2017-01-29 13:18:30 +00:00
2017-01-28 01:05:27 +00:00
2017-01-28 01:05:27 +00:00
2017-01-28 01:05:27 +00:00
2017-02-09 11:50:19 +00:00
2017-02-11 05:32:57 +00:00
2017-02-10 14:56:12 +00:00
2017-02-09 14:14:06 +00:00
2017-02-05 18:33:14 +00:00
2017-02-08 19:01:27 +00:00
2017-01-22 20:28:56 +00:00
2017-02-06 13:44:45 +00:00
2017-01-19 13:55:55 +00:00
2017-02-11 19:27:15 +00:00
2017-02-11 19:27:15 +00:00
2017-02-05 18:33:31 +00:00
2017-01-11 19:55:19 +00:00
2017-02-07 20:37:45 +00:00
2017-01-05 16:48:28 +00:00
2017-02-05 18:33:14 +00:00
2017-02-09 11:50:19 +00:00
2017-01-11 19:55:19 +00:00
2017-01-17 19:29:15 +00:00
2017-01-10 06:01:16 +00:00
2017-02-02 18:24:55 +00:00
2017-01-22 17:06:12 +00:00
2017-01-11 09:11:48 +00:00
2017-01-15 16:43:14 +00:00
2017-02-05 18:33:24 +00:00
2017-02-05 18:33:24 +00:00
2017-02-05 18:33:24 +00:00
2017-02-10 01:35:31 +00:00
2017-01-09 02:44:34 +00:00
2017-02-05 18:33:24 +00:00
2017-01-11 19:55:19 +00:00
2017-02-06 03:17:58 +00:00
2017-02-05 18:33:24 +00:00
2017-02-12 18:47:37 +00:00
2017-02-11 17:35:28 +00:00
2017-02-05 18:33:24 +00:00
2017-02-02 18:24:55 +00:00
2017-02-11 05:32:57 +00:00
2017-01-22 20:28:56 +00:00
2017-01-11 19:55:19 +00:00
2017-02-11 05:32:57 +00:00
2017-01-22 20:28:56 +00:00
2017-02-13 18:15:31 +00:00
2017-02-09 11:50:19 +00:00
2017-02-11 05:32:57 +00:00
2017-01-10 22:02:30 +00:00
2017-01-10 22:02:30 +00:00
2017-01-10 22:02:30 +00:00
2017-02-11 05:32:57 +00:00
2017-01-28 23:52:09 +00:00
2017-01-20 22:18:47 +00:00
2017-02-05 18:33:24 +00:00
2017-02-11 05:32:57 +00:00
2017-02-05 18:33:24 +00:00
2017-01-24 11:21:57 +00:00
2017-02-11 05:32:57 +00:00
2017-02-05 18:33:24 +00:00
2017-02-03 17:31:01 +00:00
2017-02-03 17:31:01 +00:00
2017-02-11 05:32:57 +00:00
2017-02-11 05:32:57 +00:00
2017-02-11 21:55:24 +00:00
2017-02-11 21:55:24 +00:00
2017-02-11 21:55:24 +00:00
2017-02-11 21:55:24 +00:00
2017-02-10 14:37:25 +00:00
2017-02-11 05:32:57 +00:00
2017-02-11 05:32:57 +00:00
2017-02-10 18:06:11 +00:00
2017-02-10 18:06:11 +00:00
2017-01-09 02:44:34 +00:00
2017-02-05 18:33:24 +00:00
2017-01-24 11:21:57 +00:00
2017-01-24 11:21:57 +00:00
2017-02-05 18:33:24 +00:00
2017-01-24 11:21:57 +00:00
2017-01-24 11:21:57 +00:00
2017-02-05 18:33:24 +00:00
2017-01-24 11:21:57 +00:00
2017-01-24 11:21:57 +00:00
2017-01-06 15:56:52 +00:00
2017-01-06 15:56:52 +00:00
2017-02-09 11:50:19 +00:00
2017-02-10 19:51:47 +00:00
2017-02-10 19:51:47 +00:00
2017-02-13 04:53:29 +00:00
2017-02-13 04:53:29 +00:00
2017-02-10 19:51:47 +00:00
2017-02-10 19:51:47 +00:00
2017-01-15 16:43:14 +00:00
2017-01-07 15:37:50 +00:00
2017-01-15 16:43:14 +00:00
2017-02-12 14:31:23 +00:00
2017-02-06 13:44:45 +00:00
2017-02-03 17:59:58 +00:00
2017-01-17 06:49:59 +00:00
2017-01-09 02:44:34 +00:00
2017-02-02 18:24:55 +00:00
2017-02-02 18:24:55 +00:00
2017-01-22 21:15:27 +00:00
2017-02-11 05:32:57 +00:00
2017-02-11 05:32:57 +00:00
2017-02-10 14:37:25 +00:00
2017-02-10 14:37:25 +00:00
2017-01-24 02:36:59 +00:00
2017-02-02 18:24:55 +00:00
2017-02-11 05:32:57 +00:00
2017-02-11 05:32:57 +00:00
2017-02-12 23:07:52 +00:00
2017-01-05 15:11:43 +00:00
2017-01-28 23:52:09 +00:00
2017-02-11 19:27:15 +00:00
2017-02-09 11:50:19 +00:00
2017-02-09 11:50:19 +00:00
2017-02-09 11:50:19 +00:00
2017-02-11 21:55:24 +00:00
2017-02-02 18:24:55 +00:00
2017-01-10 06:01:16 +00:00
2017-02-11 05:32:57 +00:00
2017-01-22 20:28:56 +00:00
2017-01-14 18:52:13 +00:00