summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Bitcode/BitcodeWriterPass.h4
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp4
-rw-r--r--llvm/test/DebugInfo/debugify-each.ll20
-rw-r--r--llvm/tools/opt/opt.cpp4
4 files changed, 29 insertions, 3 deletions
diff --git a/llvm/include/llvm/Bitcode/BitcodeWriterPass.h b/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
index ce2b80221d1..05044c9ae11 100644
--- a/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
+++ b/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
@@ -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_ostream &Str,
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
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
index cbed3d4495a..41212e575f8 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
@@ -80,3 +80,7 @@ ModulePass *llvm::createBitcodeWriterPass(raw_ostream &Str,
return new WriteBitcodePass(Str, ShouldPreserveUseListOrder,
EmitSummaryIndex, EmitModuleHash);
}
+
+bool llvm::isBitcodeWriterPass(Pass *P) {
+ return P->getPassID() == (llvm::AnalysisID)&WriteBitcodePass::ID;
+}
diff --git a/llvm/test/DebugInfo/debugify-each.ll b/llvm/test/DebugInfo/debugify-each.ll
index b3e08fff4bd..b395b268e1d 100644
--- a/llvm/test/DebugInfo/debugify-each.ll
+++ b/llvm/test/DebugInfo/debugify-each.ll
@@ -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
}
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 09f3ac82428..f1221819f62 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -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;
OpenPOWER on IntegriCloud