diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-13 01:23:21 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-13 01:23:21 +0000 |
| commit | 7e2b7567a8110abc5399e8c32ba180c87366e123 (patch) | |
| tree | 6a3a37f4ec53dd1f2d91030980d7402b3ab52333 /llvm/unittests/IR | |
| parent | b321ecbdcfc9543e8efdf469cebeb8361e8f7e97 (diff) | |
| download | bcm5719-llvm-7e2b7567a8110abc5399e8c32ba180c87366e123.tar.gz bcm5719-llvm-7e2b7567a8110abc5399e8c32ba180c87366e123.zip | |
Assert that we don't RAUW a Constant with a ConstantExpr that contains it.
We already had an assert for foo->RAUW(foo), but not for something like
foo->RAUW(GEP(foo)) and would go in an infinite loop trying to apply
the replacement.
llvm-svn: 208663
Diffstat (limited to 'llvm/unittests/IR')
| -rw-r--r-- | llvm/unittests/IR/ConstantsTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp index b3aa8102b64..59c9652e2ea 100644 --- a/llvm/unittests/IR/ConstantsTest.cpp +++ b/llvm/unittests/IR/ConstantsTest.cpp @@ -254,6 +254,23 @@ TEST(ConstantsTest, AsInstructionsTest) { P6STR ", i32 1"); } +#ifdef GTEST_HAS_DEATH_TEST +#ifndef NDEBUG +TEST(ConstantsTest, ReplaceWithConstantTest) { + std::unique_ptr<Module> M(new Module("MyModule", getGlobalContext())); + + Type *Int32Ty = Type::getInt32Ty(getGlobalContext()); + Constant *One = ConstantInt::get(Int32Ty, 1); + + Constant *Global = + M->getOrInsertGlobal("dummy", PointerType::getUnqual(Int32Ty)); + Constant *GEP = ConstantExpr::getGetElementPtr(Global, One); + EXPECT_DEATH(Global->replaceAllUsesWith(GEP), + "this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!"); +} +#endif +#endif + #undef CHECK } // end anonymous namespace |

