[PATCH] D48769: [DebugInfo][LoopVectorize] Preserve DL in generated phi instruction

Anastasis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 29 05:38:01 PDT 2018


gramanas created this revision.
gramanas added a reviewer: vsk.
Herald added subscribers: llvm-commits, JDevlieghere.

Similar to https://reviews.llvm.org/rL335904.

When creating `phi` instructions to resume at the scalar part of the loop,
copy the DebugLoc from the original phi over to the new one.


Repository:
  rL LLVM

https://reviews.llvm.org/D48769

Files:
  lib/Transforms/Vectorize/LoopVectorize.cpp
  test/Transforms/LoopVectorize/calloc.ll


Index: test/Transforms/LoopVectorize/calloc.ll
===================================================================
--- test/Transforms/LoopVectorize/calloc.ll
+++ test/Transforms/LoopVectorize/calloc.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s  -basicaa -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S | FileCheck %s
+; RUN: opt -debugify -loop-vectorize -S < %s | FileCheck %s -check-prefix DEBUGLOC
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 
@@ -42,6 +43,14 @@
   %exitcond = icmp eq i64 %inc, %0
   br i1 %exitcond, label %for.end, label %for.body
 
+; Check that the phi to resume the scalar part of the loop
+; has Debug Location.
+;
+; DEBUGLOC-LABEL: scalar.ph:
+; DEBUGLOC-NEXT:    %bc.resume.val = phi {{.*}} !dbg ![[DbgLoc:[0-9]+]]
+;
+; DEBUGLOC: ![[DbgLoc]] = !DILocation(
+
 for.end:                                          ; preds = %for.body, %entry
   ret i8* %call
 }
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2912,6 +2912,8 @@
     // Create phi nodes to merge from the  backedge-taken check block.
     PHINode *BCResumeVal = PHINode::Create(
         OrigPhi->getType(), 3, "bc.resume.val", ScalarPH->getTerminator());
+    // Copy original phi DL over to the new one.
+    BCResumeVal->setDebugLoc(OrigPhi->getDebugLoc());
     Value *&EndValue = IVEndValues[OrigPhi];
     if (OrigPhi == OldInduction) {
       // We know what the end value is.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48769.153483.patch
Type: text/x-patch
Size: 1702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180629/bfa8707f/attachment.bin>


More information about the llvm-commits mailing list