mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208663 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user