1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[ValueTracking] isGuaranteedNotToBePoison should return true on undef

This is a one-line fix to isGuaranteedNotToBePoison to return true if
undef is given.
This commit is contained in:
Juneyoung Lee 2021-01-05 06:49:19 +09:00
parent 8309f8b873
commit abd383d357
2 changed files with 5 additions and 1 deletions

View File

@ -4888,7 +4888,7 @@ static bool isGuaranteedNotToBeUndefOrPoison(const Value *V,
if (auto *C = dyn_cast<Constant>(V)) {
if (isa<UndefValue>(C))
return PoisonOnly;
return PoisonOnly && !isa<PoisonValue>(C);
if (isa<ConstantInt>(C) || isa<GlobalVariable>(C) || isa<ConstantFP>(V) ||
isa<ConstantPointerNull>(C) || isa<Function>(C))

View File

@ -884,6 +884,10 @@ TEST_F(ValueTrackingTest, isGuaranteedNotToBeUndefOrPoison) {
" ret void\n"
"}\n");
EXPECT_EQ(isGuaranteedNotToBeUndefOrPoison(A), true);
EXPECT_EQ(isGuaranteedNotToBeUndefOrPoison(UndefValue::get(IntegerType::get(Context, 8))), false);
EXPECT_EQ(isGuaranteedNotToBeUndefOrPoison(PoisonValue::get(IntegerType::get(Context, 8))), false);
EXPECT_EQ(isGuaranteedNotToBePoison(UndefValue::get(IntegerType::get(Context, 8))), true);
EXPECT_EQ(isGuaranteedNotToBePoison(PoisonValue::get(IntegerType::get(Context, 8))), false);
}
TEST_F(ValueTrackingTest, isGuaranteedNotToBeUndefOrPoison_assume) {