diff options
author | Adrian Prantl <aprantl@apple.com> | 2016-05-09 17:37:42 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2016-05-09 17:37:42 +0000 |
commit | ec45b437a79f932cd54976272675bcb05811d436 (patch) | |
tree | 6444a620626bcbb069990d3788429d01dd758b5a /llvm/unittests/IR/VerifierTest.cpp | |
parent | 4a9292b127d520349ca66b3a3d232e795c1c2b1d (diff) | |
download | llvm-ec45b437a79f932cd54976272675bcb05811d436.zip llvm-ec45b437a79f932cd54976272675bcb05811d436.tar.gz llvm-ec45b437a79f932cd54976272675bcb05811d436.tar.bz2 |
Separate the Verifier into an analysis and a transformation pass and
allow the transformation to strip invalid debug info.
This patch separates the Verifier into an analysis and a transformation
pass, with the transformation pass optionally stripping malformed
debug info.
The problem I'm trying to solve with this sequence of patches is that
historically we've done a really bad job at verifying debug info. We want
to be able to make the verifier stricter without having to worry about
breaking bitcode compatibility with existing producers. For example, we
don't necessarily want IR produced by an older version of clang to be
rejected by an LTO link just because of malformed debug info, and rather
provide an option to strip it. Note that merely outdated (but well-formed)
debug info would continue to be auto-upgraded in this scenario.
http://reviews.llvm.org/D19988
rdar://problem/25818489
llvm-svn: 268937
Diffstat (limited to 'llvm/unittests/IR/VerifierTest.cpp')
-rw-r--r-- | llvm/unittests/IR/VerifierTest.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp index 8b95173..1fc50da 100644 --- a/llvm/unittests/IR/VerifierTest.cpp +++ b/llvm/unittests/IR/VerifierTest.cpp @@ -144,5 +144,30 @@ TEST(VerifierTest, CrossModuleMetadataRef) { EXPECT_TRUE(StringRef(ErrorOS.str()) .startswith("Referencing global in another module!")); } + +TEST(VerifierTest, StripInvalidDebugInfo) { + LLVMContext C; + Module M("M", C); + DIBuilder DIB(M); + DIB.createCompileUnit(dwarf::DW_LANG_C89, "broken.c", "/", + "unittest", false, "", 0); + DIB.finalize(); + EXPECT_FALSE(verifyModule(M)); + + // Now break it. + auto *File = DIB.createFile("not-a-CU.f", "."); + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu"); + NMD->addOperand(File); + EXPECT_TRUE(verifyModule(M)); + + ModulePassManager MPM(true); + MPM.addPass(VerifierPass(false)); + ModuleAnalysisManager MAM(true); + MAM.registerPass([&] { return VerifierAnalysis(); }); + MPM.run(M, MAM); + EXPECT_FALSE(verifyModule(M)); +} + + } // end anonymous namespace } // end namespace llvm |