[llvm] r333861 - [Debugify] Don't apply DI before the bitcode writer pass
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 3 17:11:49 PDT 2018
Author: vedantk
Date: Sun Jun 3 17:11:49 2018
New Revision: 333861
URL: http://llvm.org/viewvc/llvm-project?rev=333861&view=rev
Log:
[Debugify] Don't apply DI before the bitcode writer pass
Applying synthetic debug info before the bitcode writer pass has no
testing-related purpose. This commit prevents that from happening.
It also adds tests which check that IR produced with/without
-debugify-each enabled is identical after stripping. This makes it
possible to check that individual passes (or full pipelines) are
invariant to debug info.
Modified:
llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h
llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp
llvm/trunk/test/DebugInfo/debugify-each.ll
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h?rev=333861&r1=333860&r2=333861&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h (original)
+++ llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h Sun Jun 3 17:11:49 2018
@@ -21,6 +21,7 @@
namespace llvm {
class Module;
class ModulePass;
+class Pass;
class raw_ostream;
/// Create and return a pass that writes the module to the specified
@@ -40,6 +41,9 @@ ModulePass *createBitcodeWriterPass(raw_
bool EmitSummaryIndex = false,
bool EmitModuleHash = false);
+/// Check whether a pass is a BitcodeWriterPass.
+bool isBitcodeWriterPass(Pass *P);
+
/// Pass for writing a module of IR out to a bitcode file.
///
/// Note that this is intended for use with the new pass manager. To construct
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp?rev=333861&r1=333860&r2=333861&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp Sun Jun 3 17:11:49 2018
@@ -80,3 +80,7 @@ ModulePass *llvm::createBitcodeWriterPas
return new WriteBitcodePass(Str, ShouldPreserveUseListOrder,
EmitSummaryIndex, EmitModuleHash);
}
+
+bool llvm::isBitcodeWriterPass(Pass *P) {
+ return P->getPassID() == (llvm::AnalysisID)&WriteBitcodePass::ID;
+}
Modified: llvm/trunk/test/DebugInfo/debugify-each.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debugify-each.ll?rev=333861&r1=333860&r2=333861&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/debugify-each.ll (original)
+++ llvm/trunk/test/DebugInfo/debugify-each.ll Sun Jun 3 17:11:49 2018
@@ -13,7 +13,25 @@
; Verify that debugify each can be safely used with piping
; RUN: opt -debugify-each -O1 < %s | opt -O2 -o /dev/null
-define void @foo() {
+; Check that stripped textual IR compares equal before and after applying
+; debugify.
+; RUN: opt -O1 < %s -S -o - | \
+; RUN: opt -strip -strip-dead-prototypes -strip-module-flags -S -o %t.before
+; RUN: opt -O1 -debugify-each < %s -S -o - | \
+; RUN: opt -strip -strip-dead-prototypes -strip-module-flags -S -o %t.after
+; RUN: diff %t.before %t.after
+
+; Check that stripped IR compares equal before and after applying debugify.
+; RUN: opt -O1 < %s | \
+; RUN: opt -strip -strip-dead-prototypes -strip-module-flags | \
+; RUN: llvm-dis -o %t.before
+; RUN: opt -O1 -debugify-each < %s | \
+; RUN: opt -strip -strip-dead-prototypes -strip-module-flags | \
+; RUN: llvm-dis -o %t.after
+; RUN: diff %t.before %t.after
+
+define void @foo(i32 %arg) {
+ call i32 asm "bswap $0", "=r,r"(i32 %arg)
ret void
}
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=333861&r1=333860&r2=333861&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Sun Jun 3 17:11:49 2018
@@ -269,8 +269,8 @@ public:
using super = legacy::PassManager;
void add(Pass *P) override {
- bool WrapWithDebugify =
- DebugifyEach && !P->getAsImmutablePass() && !isIRPrintingPass(P);
+ bool WrapWithDebugify = DebugifyEach && !P->getAsImmutablePass() &&
+ !isIRPrintingPass(P) && !isBitcodeWriterPass(P);
if (!WrapWithDebugify) {
super::add(P);
return;
More information about the llvm-commits
mailing list