1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-24 05:23:45 +02:00
llvm-mirror/test/Transforms/LoopSimplify
Taewook Oh 4f36d58559 [BasicBlockUtils] Use getFirstNonPHIOrDbg to set debugloc for instructions created in SplitBlockPredecessors
Summary:
When setting debugloc for instructions created in SplitBlockPredecessors, current implementation copies debugloc from the first-non-phi instruction of the original basic block. However, if the first-non-phi instruction is a call for @llvm.dbg.value, the debugloc of the instruction may point the location outside of the block itself. For the example code of

```
  1 typedef struct _node_t {
  2   struct _node_t *next;
  3 } node_t;
  4
  5 extern node_t *root;
  6
  7 int foo() {
  8   node_t *node, *tmp;
  9   int ret = 0;
 10
 11   node = tmp = root->next;
 12   while (node != root) {
 13     while (node) {
 14       tmp = node;
 15       node = node->next;
 16       ret++;
 17     }
 18   }
 19
 20   return ret;
 21 }
```

, below is the basicblock corresponding to line 12 after Reassociate expressions pass:

```
while.cond:                                       ; preds = %while.cond2, %entry
  %node.0 = phi %struct._node_t* [ %1, %entry ], [ null, %while.cond2 ]
  %ret.0 = phi i32 [ 0, %entry ], [ %ret.1, %while.cond2 ]
  tail call void @llvm.dbg.value(metadata i32 %ret.0, i64 0, metadata !19, metadata !20), !dbg !21
  tail call void @llvm.dbg.value(metadata %struct._node_t* %node.0, i64 0, metadata !11, metadata !20), !dbg !31
  %cmp = icmp eq %struct._node_t* %node.0, %0, !dbg !33
  br i1 %cmp, label %while.end5, label %while.cond2, !dbg !35
```

As you can see, the first-non-phi instruction is a call for @llvm.dbg.value, and the debugloc is

```
!21 = !DILocation(line: 9, column: 7, scope: !6)
```

, which is a definition of 'ret' variable and outside of the scope of the basicblock itself. However, current implementation picks up this debugloc for the instructions created in SplitBlockPredecessors. This patch addresses this problem by picking up debugloc from the first-non-phi-non-dbg instruction.

Reviewers: dblaikie, samsonov, eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D29867

llvm-svn: 295106
2017-02-14 21:10:40 +00:00
..
2003-04-25-AssertFail.ll
2003-05-12-PreheaderExitOfChild.ll
2003-08-15-PreheadersFail.ll
2003-12-10-ExitBlocksProblem.ll
2004-02-05-DominatorInfoCorruption.ll
2004-03-15-IncorrectDomUpdate.ll
2004-04-01-IncorrectDomUpdate.ll
2004-04-12-LoopSimplify-SwitchBackedges.ll
2004-04-13-LoopSimplifyUpdateDomFrontier.ll
2007-10-28-InvokeCrash.ll
2010-07-15-IncorrectDomFrontierUpdate.ll
2010-12-26-PHIInfiniteLoop.ll
2011-12-14-LandingpadHeader.ll
2012-03-20-indirectbr.ll
ashr-crash.ll
basictest.ll
dbg-loc.ll [BasicBlockUtils] Use getFirstNonPHIOrDbg to set debugloc for instructions created in SplitBlockPredecessors 2017-02-14 21:10:40 +00:00
dup-preds.ll
hardertest.ll
indirectbr-backedge.ll
indirectbr.ll
merge-exits.ll
notify-scev.ll
phi-node-simplify.ll
pr26682.ll
pr28272.ll
pr30454.ll
preserve-llvm-loop-metadata.ll
preserve-scev.ll
single-backedge.ll
unreachable-loop-pred.ll