[llvm-branch-commits] [llvm] 24b8143 - Add tests, code style fixes

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jan 15 07:30:24 PST 2020


Author: gbtozers
Date: 2020-01-15T15:30:13Z
New Revision: 24b81434a056825f4e9dd3ef06bad7a2ef34f813

URL: https://github.com/llvm/llvm-project/commit/24b81434a056825f4e9dd3ef06bad7a2ef34f813
DIFF: https://github.com/llvm/llvm-project/commit/24b81434a056825f4e9dd3ef06bad7a2ef34f813.diff

LOG: Add tests, code style fixes

Added: 
    llvm/test/Transforms/DCE/pure-undef-dbg-inst-elim.ll

Modified: 
    llvm/include/llvm/InitializePasses.h
    llvm/include/llvm/LinkAllPasses.h
    llvm/include/llvm/Transforms/Scalar.h
    llvm/lib/Transforms/Scalar/DCE.cpp
    llvm/lib/Transforms/Scalar/Scalar.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index c59170da05a0..647b3a34722c 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -342,12 +342,12 @@ void initializeProcessImplicitDefsPass(PassRegistry&);
 void initializeProfileSummaryInfoWrapperPassPass(PassRegistry&);
 void initializePromoteLegacyPassPass(PassRegistry&);
 void initializePruneEHPass(PassRegistry&);
+void initializePureUndefDbgInstEliminationPass(PassRegistry&);
 void initializeRABasicPass(PassRegistry&);
 void initializeRAGreedyPass(PassRegistry&);
 void initializeReachingDefAnalysisPass(PassRegistry&);
 void initializeReassociateLegacyPassPass(PassRegistry&);
 void initializeRedundantDbgInstEliminationPass(PassRegistry&);
-void initializePureUndefDbgInstEliminationPass(PassRegistry&);
 void initializeRegAllocFastPass(PassRegistry&);
 void initializeRegBankSelectPass(PassRegistry&);
 void initializeRegToMemPass(PassRegistry&);

diff  --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h
index 9dcf5958029e..962329219b0b 100644
--- a/llvm/include/llvm/LinkAllPasses.h
+++ b/llvm/include/llvm/LinkAllPasses.h
@@ -158,9 +158,9 @@ namespace {
       (void) llvm::createPostDomPrinterPass();
       (void) llvm::createPostDomOnlyViewerPass();
       (void) llvm::createPostDomViewerPass();
+      (void) llvm::createPureUndefDbgInstEliminationPass();
       (void) llvm::createReassociatePass();
       (void) llvm::createRedundantDbgInstEliminationPass();
-      (void) llvm::createPureUndefDbgInstEliminationPass();
       (void) llvm::createRegionInfoPass();
       (void) llvm::createRegionOnlyPrinterPass();
       (void) llvm::createRegionOnlyViewerPass();

diff  --git a/llvm/include/llvm/Transforms/Scalar.h b/llvm/include/llvm/Transforms/Scalar.h
index 85c931bb20d1..0b4f605ac95f 100644
--- a/llvm/include/llvm/Transforms/Scalar.h
+++ b/llvm/include/llvm/Transforms/Scalar.h
@@ -55,18 +55,18 @@ Pass *createDeadInstEliminationPass();
 
 //===----------------------------------------------------------------------===//
 //
-// RedundantDbgInstElimination - This pass removes redundant dbg intrinsics
-// without modifying the CFG of the function.  It is a FunctionPass.
+// PureUndefDbgInstElimination - This pass removes dbg intrinsics for variables
+// that are always `undef` within a function, without modifying the CFG of the
+// function.  It is a FunctionPass.
 //
-Pass *createRedundantDbgInstEliminationPass();
+Pass *createPureUndefDbgInstEliminationPass();
 
 //===----------------------------------------------------------------------===//
 //
-// PureUndefDbgInstElimination - This pass removes dbg intrinsics for variables
-// which are always `undef` within a function, without modifying the CFG of the
-// function.  It is a FunctionPass.
+// RedundantDbgInstElimination - This pass removes redundant dbg intrinsics
+// without modifying the CFG of the function.  It is a FunctionPass.
 //
-Pass *createPureUndefDbgInstEliminationPass();
+Pass *createRedundantDbgInstEliminationPass();
 
 //===----------------------------------------------------------------------===//
 //

diff  --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp
index 615ca5e31333..e7afdf26e699 100644
--- a/llvm/lib/Transforms/Scalar/DCE.cpp
+++ b/llvm/lib/Transforms/Scalar/DCE.cpp
@@ -121,7 +121,7 @@ Pass *llvm::createRedundantDbgInstEliminationPass() {
 
 namespace {
 struct PureUndefDbgInstElimination : public FunctionPass {
-  static char ID; // Pass identification, replacement for typeid
+  static char ID; // Pass identification, replacement for typeid.
   PureUndefDbgInstElimination() : FunctionPass(ID) {
     initializePureUndefDbgInstEliminationPass(*PassRegistry::getPassRegistry());
   }

diff  --git a/llvm/lib/Transforms/Scalar/Scalar.cpp b/llvm/lib/Transforms/Scalar/Scalar.cpp
index b0d38ab82874..23e049625254 100644
--- a/llvm/lib/Transforms/Scalar/Scalar.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalar.cpp
@@ -89,9 +89,9 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
   initializeMergedLoadStoreMotionLegacyPassPass(Registry);
   initializeNaryReassociateLegacyPassPass(Registry);
   initializePartiallyInlineLibCallsLegacyPassPass(Registry);
+  initializePureUndefDbgInstEliminationPass(Registry);
   initializeReassociateLegacyPassPass(Registry);
   initializeRedundantDbgInstEliminationPass(Registry);
-  initializePureUndefDbgInstEliminationPass(Registry);
   initializeRegToMemPass(Registry);
   initializeRewriteStatepointsForGCLegacyPassPass(Registry);
   initializeSCCPLegacyPassPass(Registry);

diff  --git a/llvm/test/Transforms/DCE/pure-undef-dbg-inst-elim.ll b/llvm/test/Transforms/DCE/pure-undef-dbg-inst-elim.ll
new file mode 100644
index 000000000000..475c6f248a7f
--- /dev/null
+++ b/llvm/test/Transforms/DCE/pure-undef-dbg-inst-elim.ll
@@ -0,0 +1,57 @@
+; RUN: opt < %s -pure-undef-dbg-inst-elim -S | FileCheck %s
+
+; Compiled with "clang -O2 -S -emit-llvm -g"
+;
+; int foo(int a) {
+;     int b = 2, c;
+;     if (a) {
+;         b = 4;
+;         c = 6;
+;     } else {
+;         c = 7;
+;     }
+;     return b + c;
+; }
+
+
+define dso_local i32 @"?foo@@YAHH at Z"(i32 %a) local_unnamed_addr !dbg !8 {
+; CHECK-LABEL: entry:
+; CHECK: call void @llvm.dbg.value(metadata i32 %a, metadata ![[A:[0-9]+]]
+; CHECK: call void @llvm.dbg.value(metadata i32 2, metadata ![[B:[0-9]+]]
+; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata ![[B]]
+; CHECK-NOT: call void @llvm.dbg.value(
+entry:
+  call void @llvm.dbg.value(metadata i32 %a, metadata !14, metadata !DIExpression()), !dbg !17
+  call void @llvm.dbg.value(metadata i32 2, metadata !15, metadata !DIExpression()), !dbg !17
+  %tobool = icmp eq i32 %a, 0, !dbg !18
+  call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !17
+  call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !17
+  %add = select i1 %tobool, i32 9, i32 10, !dbg !19
+  ret i32 %add, !dbg !19
+}
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "test.cpp", directory: "/", checksumkind: CSK_MD5, checksum: "8954cc09af7e1495ea12d23a9d6376c9")
+!2 = !{}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 2}
+!6 = !{i32 7, !"PIC Level", i32 2}
+!7 = !{!"clang version 10.0.0"}
+!8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAHH at Z", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
+!9 = !DIFile(filename: "test.cpp", directory: "/", checksumkind: CSK_MD5, checksum: "8954cc09af7e1495ea12d23a9d6376c9")
+!10 = !DISubroutineType(types: !11)
+!11 = !{!12, !12}
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !{!14, !15, !16}
+!14 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !9, line: 1, type: !12)
+!15 = !DILocalVariable(name: "b", scope: !8, file: !9, line: 2, type: !12)
+!16 = !DILocalVariable(name: "c", scope: !8, file: !9, line: 2, type: !12)
+!17 = !DILocation(line: 0, scope: !8)
+!18 = !DILocation(line: 3, scope: !8)
+!19 = !DILocation(line: 9, scope: !8)


        


More information about the llvm-branch-commits mailing list