diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-10-02 18:31:29 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-10-02 18:31:29 +0000 |
commit | a8b2ddbde453fab0db90be21b9a1ff961a7770e0 (patch) | |
tree | 190712a839a2ce48d61e75501d2f68440891a2d8 /llvm/unittests/IR/VerifierTest.cpp | |
parent | 6e17c00a88e23d0cc4cb491bfd0830f3df7fff66 (diff) | |
download | bcm5719-llvm-a8b2ddbde453fab0db90be21b9a1ff961a7770e0.tar.gz bcm5719-llvm-a8b2ddbde453fab0db90be21b9a1ff961a7770e0.zip |
Move the stripping of invalid debug info from the Verifier to AutoUpgrade.
This came out of a recent discussion on llvm-dev
(https://reviews.llvm.org/D38042). Currently the Verifier will strip
the debug info metadata from a module if it finds the dbeug info to be
malformed. This feature is very valuable since it allows us to improve
the Verifier by making it stricter without breaking bcompatibility,
but arguable the Verifier pass should not be modifying the IR. This
patch moves the stripping of broken debug info into AutoUpgrade
(UpgradeDebugInfo to be precise), which is a much better location for
this since the stripping of malformed (i.e., produced by older, buggy
versions of Clang) is a (harsh) form of AutoUpgrade.
This change is mostly NFC in nature, the one big difference is the
behavior when LLVM module passes are introducing malformed debug
info. Prior to this patch, a NoAsserts build would have printed a
warning and stripped the debug info, after this patch the Verifier
will report a fatal error. I believe this behavior is actually more
desirable anyway.
Differential Revision: https://reviews.llvm.org/D38184
llvm-svn: 314699
Diffstat (limited to 'llvm/unittests/IR/VerifierTest.cpp')
-rw-r--r-- | llvm/unittests/IR/VerifierTest.cpp | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp index f1f453ed5d1..ac94eb102d6 100644 --- a/llvm/unittests/IR/VerifierTest.cpp +++ b/llvm/unittests/IR/VerifierTest.cpp @@ -17,7 +17,6 @@ #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" -#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Module.h" #include "gtest/gtest.h" @@ -149,7 +148,7 @@ TEST(VerifierTest, InvalidFunctionLinkage) { "have external or weak linkage!")); } -TEST(VerifierTest, StripInvalidDebugInfo) { +TEST(VerifierTest, DetectInvalidDebugInfo) { { LLVMContext C; Module M("M", C); @@ -164,13 +163,6 @@ TEST(VerifierTest, StripInvalidDebugInfo) { 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)); } { LLVMContext C; @@ -195,36 +187,8 @@ TEST(VerifierTest, StripInvalidDebugInfo) { // Now break it by not listing the CU at all. M.eraseNamedMetadata(M.getOrInsertNamedMetadata("llvm.dbg.cu")); 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)); } } -TEST(VerifierTest, StripInvalidDebugInfoLegacy) { - LLVMContext C; - Module M("M", C); - DIBuilder DIB(M); - DIB.createCompileUnit(dwarf::DW_LANG_C89, DIB.createFile("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)); - - legacy::PassManager Passes; - Passes.add(createVerifierPass(false)); - Passes.run(M); - EXPECT_FALSE(verifyModule(M)); -} - } // end anonymous namespace } // end namespace llvm |