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. 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 }