[llvm] r325660 - [BDCE] Salvage debug info from dying insts

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 17:55:33 PST 2018


Author: vedantk
Date: Tue Feb 20 17:55:33 2018
New Revision: 325660

URL: http://llvm.org/viewvc/llvm-project?rev=325660&view=rev
Log:
[BDCE] Salvage debug info from dying insts

This results in 15 additional unique source variables in a stage2 build
of FileCheck (at '-Os -g'), with a negligible increase in the size of
the .debug_loc section.

Modified:
    llvm/trunk/lib/Transforms/Scalar/BDCE.cpp
    llvm/trunk/test/Transforms/BDCE/basic.ll

Modified: llvm/trunk/lib/Transforms/Scalar/BDCE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/BDCE.cpp?rev=325660&r1=325659&r2=325660&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/BDCE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/BDCE.cpp Tue Feb 20 17:55:33 2018
@@ -26,6 +26,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/Scalar.h"
+#include "llvm/Transforms/Utils/Local.h"
 using namespace llvm;
 
 #define DEBUG_TYPE "bdce"
@@ -114,6 +115,7 @@ static bool bitTrackingDCE(Function &F,
     if (!DB.isInstructionDead(&I))
       continue;
 
+    salvageDebugInfo(I);
     Worklist.push_back(&I);
     I.dropAllReferences();
     Changed = true;

Modified: llvm/trunk/test/Transforms/BDCE/basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/BDCE/basic.ll?rev=325660&r1=325659&r2=325660&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/BDCE/basic.ll (original)
+++ llvm/trunk/test/Transforms/BDCE/basic.ll Tue Feb 20 17:55:33 2018
@@ -1,5 +1,6 @@
 ; RUN: opt -S -bdce -instsimplify < %s | FileCheck %s
 ; RUN: opt -S -instsimplify < %s | FileCheck %s -check-prefix=CHECK-IO
+; RUN: opt -S -debugify -bdce < %s | FileCheck %s -check-prefix=DEBUGIFY
 target datalayout = "E-m:e-i64:64-n32:64"
 target triple = "powerpc64-unknown-linux-gnu"
 
@@ -381,6 +382,16 @@ entry:
 ; CHECK: ret i16
 }
 
+; DEBUGIFY-LABEL: @tar9
+define signext i16 @tar9(i32 signext %x) #0 {
+entry:
+  %call = tail call signext i32 @foo(i32 signext 5) #0
+  %and = and i32 %call, 33554432
+; DEBUGIFY: call void @llvm.dbg.value(metadata i32 %call, metadata {{.*}}, metadata !DIExpression(DW_OP_constu, 33554432, DW_OP_and, DW_OP_stack_value))
+  %cast = trunc i32 %call to i16
+  ret i16 %cast
+}
+
 attributes #0 = { nounwind readnone }
 attributes #1 = { nounwind }
 




More information about the llvm-commits mailing list