OSDN Git Service

[Debugify] Preserve analyses in -check-debugify
authorVedant Kumar <vsk@apple.com>
Mon, 4 Jun 2018 21:43:28 +0000 (21:43 +0000)
committerVedant Kumar <vsk@apple.com>
Mon, 4 Jun 2018 21:43:28 +0000 (21:43 +0000)
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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333959 91177308-0d34-0410-b5e6-96231b3b80d8

test/DebugInfo/check-debugify-preserves-analyses.ll [new file with mode: 0644]
tools/opt/Debugify.cpp

diff --git a/test/DebugInfo/check-debugify-preserves-analyses.ll b/test/DebugInfo/check-debugify-preserves-analyses.ll
new file mode 100644 (file)
index 0000000..58b865f
--- /dev/null
@@ -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
+}
index 0a900a5..f2d7998 100644 (file)
@@ -275,6 +275,10 @@ struct CheckDebugifyModulePass : public ModulePass {
   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: