llvm.org GIT mirror llvm / f66cfed
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333861 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 2 years ago
4 changed file(s) with 29 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
2020 namespace llvm {
2121 class Module;
2222 class ModulePass;
23 class Pass;
2324 class raw_ostream;
2425
2526 /// Create and return a pass that writes the module to the specified
3839 bool ShouldPreserveUseListOrder = false,
3940 bool EmitSummaryIndex = false,
4041 bool EmitModuleHash = false);
42
43 /// Check whether a pass is a BitcodeWriterPass.
44 bool isBitcodeWriterPass(Pass *P);
4145
4246 /// Pass for writing a module of IR out to a bitcode file.
4347 ///
7979 return new WriteBitcodePass(Str, ShouldPreserveUseListOrder,
8080 EmitSummaryIndex, EmitModuleHash);
8181 }
82
83 bool llvm::isBitcodeWriterPass(Pass *P) {
84 return P->getPassID() == (llvm::AnalysisID)&WriteBitcodePass::ID;
85 }
1212 ; Verify that debugify each can be safely used with piping
1313 ; RUN: opt -debugify-each -O1 < %s | opt -O2 -o /dev/null
1414
15 define void @foo() {
15 ; Check that stripped textual IR compares equal before and after applying
16 ; debugify.
17 ; RUN: opt -O1 < %s -S -o - | \
18 ; RUN: opt -strip -strip-dead-prototypes -strip-module-flags -S -o %t.before
19 ; RUN: opt -O1 -debugify-each < %s -S -o - | \
20 ; RUN: opt -strip -strip-dead-prototypes -strip-module-flags -S -o %t.after
21 ; RUN: diff %t.before %t.after
22
23 ; Check that stripped IR compares equal before and after applying debugify.
24 ; RUN: opt -O1 < %s | \
25 ; RUN: opt -strip -strip-dead-prototypes -strip-module-flags | \
26 ; RUN: llvm-dis -o %t.before
27 ; RUN: opt -O1 -debugify-each < %s | \
28 ; RUN: opt -strip -strip-dead-prototypes -strip-module-flags | \
29 ; RUN: llvm-dis -o %t.after
30 ; RUN: diff %t.before %t.after
31
32 define void @foo(i32 %arg) {
33 call i32 asm "bswap $0", "=r,r"(i32 %arg)
1634 ret void
1735 }
1836
268268 using super = legacy::PassManager;
269269
270270 void add(Pass *P) override {
271 bool WrapWithDebugify =
272 DebugifyEach && !P->getAsImmutablePass() && !isIRPrintingPass(P);
271 bool WrapWithDebugify = DebugifyEach && !P->getAsImmutablePass() &&
272 !isIRPrintingPass(P) && !isBitcodeWriterPass(P);
273273 if (!WrapWithDebugify) {
274274 super::add(P);
275275 return;