diff options
| author | Keno Fischer <kfischer@college.harvard.edu> | 2016-01-14 22:42:02 +0000 |
|---|---|---|
| committer | Keno Fischer <kfischer@college.harvard.edu> | 2016-01-14 22:42:02 +0000 |
| commit | f6d17b953ca1fe8a79927e1ccfe0b2a2238d4965 (patch) | |
| tree | 5d877e29e3cd0c4c889a9fca43d589dbb6d898b0 /llvm/unittests/IR | |
| parent | d0281d875cbc16325c59a160d83bb92a8e8d93f1 (diff) | |
| download | bcm5719-llvm-f6d17b953ca1fe8a79927e1ccfe0b2a2238d4965.tar.gz bcm5719-llvm-f6d17b953ca1fe8a79927e1ccfe0b2a2238d4965.zip | |
[Verifier] Check parentage of GVs in dbg metadata
Summary:
Before this the Verifier didn't complain if the GlobalVariable
referenced from a DIGlobalVariable was not in fact in the correct
module (it would crash while writing bitcode though). Fix this by
always checking parantage of GlobalValues while walking constant
expressions and changing the DIGlobalVariable visitor to also
visit the constant it contains.
Reviewers: rafael
Differential Revision: http://reviews.llvm.org/D16059
llvm-svn: 257825
Diffstat (limited to 'llvm/unittests/IR')
| -rw-r--r-- | llvm/unittests/IR/VerifierTest.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp index 7ae346d00c1..c24e8d732b5 100644 --- a/llvm/unittests/IR/VerifierTest.cpp +++ b/llvm/unittests/IR/VerifierTest.cpp @@ -9,6 +9,7 @@ #include "llvm/IR/Verifier.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DIBuilder.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" #include "llvm/IR/GlobalAlias.h" @@ -119,7 +120,28 @@ TEST(VerifierTest, CrossModuleRef) { F3->eraseFromParent(); } +TEST(VerifierTest, CrossModuleMetadataRef) { + LLVMContext &C = getGlobalContext(); + Module M1("M1", C); + Module M2("M2", C); + GlobalVariable *newGV = + new GlobalVariable(M1, Type::getInt8Ty(C), false, + GlobalVariable::ExternalLinkage, NULL, "Some Global"); + + DIBuilder dbuilder(M2); + auto CU = dbuilder.createCompileUnit(dwarf::DW_LANG_Julia, "test.jl", ".", + "unittest", false, "", 0); + auto File = dbuilder.createFile("test.jl", "."); + auto Ty = dbuilder.createBasicType("Int8", 8, 8, dwarf::DW_ATE_signed); + dbuilder.createGlobalVariable(CU, "_SOME_GLOBAL", "_SOME_GLOBAL", File, 1, Ty, + false, newGV); + dbuilder.finalize(); - + std::string Error; + raw_string_ostream ErrorOS(Error); + EXPECT_TRUE(verifyModule(M2, &ErrorOS)); + EXPECT_TRUE(StringRef(ErrorOS.str()) + .startswith("Referencing global in another module!")); +} } } |

