[llvm] r333959 - [Debugify] Preserve analyses in -check-debugify

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 4 14:43:28 PDT 2018


Author: vedantk
Date: Mon Jun  4 14:43:28 2018
New Revision: 333959

URL: http://llvm.org/viewvc/llvm-project?rev=333959&view=rev
Log:
[Debugify] Preserve analyses in -check-debugify

The -check-debugify pass should preserve all analyses. Otherwise, it may
invalidate an optional analysis and inadvertently alter codegen.

The test case is reduced from deopt-bundle.ll. The result of `opt -O1`
on this file would differ when -debugify-each was toggled. That happened
because CheckDebugify failed to preserve GlobalsAA.

Thanks to Davide Italiano for his help chasing this down!

Added:
    llvm/trunk/test/DebugInfo/check-debugify-preserves-analyses.ll
Modified:
    llvm/trunk/tools/opt/Debugify.cpp

Added: llvm/trunk/test/DebugInfo/check-debugify-preserves-analyses.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/check-debugify-preserves-analyses.ll?rev=333959&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/check-debugify-preserves-analyses.ll (added)
+++ llvm/trunk/test/DebugInfo/check-debugify-preserves-analyses.ll Mon Jun  4 14:43:28 2018
@@ -0,0 +1,12 @@
+; RUN: opt < %s -globals-aa -functionattrs | \
+; RUN:   opt -S -strip -strip-dead-prototypes -strip-module-flags > %t.no_dbg
+
+; RUN: opt < %s -debugify-each -globals-aa -functionattrs | \
+; RUN:   opt -S -strip -strip-dead-prototypes -strip-module-flags > %t.with_dbg
+
+; RUN: diff %t.no_dbg %t.with_dbg
+
+define i32 @f_1(i32 %x) {
+  %tmp = call i32 @f_1(i32 0) [ "deopt"() ]
+  ret i32 0
+}

Modified: llvm/trunk/tools/opt/Debugify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/Debugify.cpp?rev=333959&r1=333958&r2=333959&view=diff
==============================================================================
--- llvm/trunk/tools/opt/Debugify.cpp (original)
+++ llvm/trunk/tools/opt/Debugify.cpp Mon Jun  4 14:43:28 2018
@@ -275,6 +275,10 @@ struct CheckDebugifyModulePass : public
   CheckDebugifyModulePass(bool Strip = false, StringRef NameOfWrappedPass = "")
       : ModulePass(ID), Strip(Strip), NameOfWrappedPass(NameOfWrappedPass) {}
 
+  void getAnalysisUsage(AnalysisUsage &AU) const override {
+    AU.setPreservesAll();
+  }
+
   static char ID; // Pass identification.
 
 private:




More information about the llvm-commits mailing list