From 282b26ec4d988fe300cda4d8f273a42cf4e0923d Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Fri, 19 Apr 2019 22:36:40 +0000 Subject: [GVN+LICM] Use line 0 locations for better crash attribution This is a follow-up to r291037+r291258, which used null debug locations to prevent jumpy line tables. Using line 0 locations achieves the same effect, but works better for crash attribution because it preserves the right inline scope. Differential Revision: https://reviews.llvm.org/D60913 llvm-svn: 358791 --- llvm/lib/Transforms/Scalar/LICM.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/LICM.cpp') diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index 31841773375..dcbf2d42c54 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -54,6 +54,7 @@ #include "llvm/IR/CFG.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Instructions.h" @@ -1652,13 +1653,10 @@ static void hoist(Instruction &I, const DominatorTree *DT, const Loop *CurLoop, // Move the new node to the destination block, before its terminator. moveInstructionBefore(I, *Dest->getTerminator(), *SafetyInfo, MSSAU); - // Do not retain debug locations when we are moving instructions to different - // basic blocks, because we want to avoid jumpy line tables. Calls, however, - // need to retain their debug locs because they may be inlined. - // FIXME: How do we retain source locations without causing poor debugging - // behavior? - if (!isa(I)) - I.setDebugLoc(DebugLoc()); + // Apply line 0 debug locations when we are moving instructions to different + // basic blocks because we want to avoid jumpy line tables. + if (const DebugLoc &DL = I.getDebugLoc()) + I.setDebugLoc(DebugLoc::get(0, 0, DL.getScope(), DL.getInlinedAt())); if (isa(I)) ++NumMovedLoads; -- cgit v1.2.3