Skip to content

[llvm] Replace UndefValue::get with PoisonValue::get in unit test #115985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

leewei05
Copy link
Contributor

Since these UndefValue::get are acted as placeholders, I think it's safe to replace them with poison values.
There are a lot of UndefValue::get in LLVM, I'll start fixing the ones in unittests while fixing the regression tests.

@nunoplopes @regehr

@leewei05 leewei05 requested a review from nunoplopes November 13, 2024 04:11
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Nov 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2024

@llvm/pr-subscribers-llvm-analysis

Author: Lee Wei (leewei05)

Changes

Since these UndefValue::get are acted as placeholders, I think it's safe to replace them with poison values.
There are a lot of UndefValue::get in LLVM, I'll start fixing the ones in unittests while fixing the regression tests.

@nunoplopes @regehr


Full diff: https://github.com/llvm/llvm-project/pull/115985.diff

1 Files Affected:

  • (modified) llvm/unittests/Analysis/PhiValuesTest.cpp (+11-11)
diff --git a/llvm/unittests/Analysis/PhiValuesTest.cpp b/llvm/unittests/Analysis/PhiValuesTest.cpp
index 149feb15d999f1..1cd8c96b33c6eb 100644
--- a/llvm/unittests/Analysis/PhiValuesTest.cpp
+++ b/llvm/unittests/Analysis/PhiValuesTest.cpp
@@ -34,14 +34,14 @@ TEST(PhiValuesTest, SimplePhi) {
   BasicBlock *If = BasicBlock::Create(C, "if", F);
   BasicBlock *Else = BasicBlock::Create(C, "else", F);
   BasicBlock *Then = BasicBlock::Create(C, "then", F);
-  BranchInst::Create(If, Else, UndefValue::get(I1Ty), Entry);
+  BranchInst::Create(If, Else, PoisonValue::get(I1Ty), Entry);
   BranchInst::Create(Then, If);
   BranchInst::Create(Then, Else);
 
-  Value *Val1 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val1", Entry);
-  Value *Val2 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val2", Entry);
-  Value *Val3 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val3", Entry);
-  Value *Val4 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val4", Entry);
+  Value *Val1 = new LoadInst(I32Ty, PoisonValue::get(PtrTy), "val1", Entry);
+  Value *Val2 = new LoadInst(I32Ty, PoisonValue::get(PtrTy), "val2", Entry);
+  Value *Val3 = new LoadInst(I32Ty, PoisonValue::get(PtrTy), "val3", Entry);
+  Value *Val4 = new LoadInst(I32Ty, PoisonValue::get(PtrTy), "val4", Entry);
 
   PHINode *Phi1 = PHINode::Create(I32Ty, 2, "phi1", Then);
   Phi1->addIncoming(Val1, If);
@@ -104,17 +104,17 @@ TEST(PhiValuesTest, DependentPhi) {
   BasicBlock *If2 = BasicBlock::Create(C, "if2", F);
   BasicBlock *Else2 = BasicBlock::Create(C, "else2", F);
   BasicBlock *End = BasicBlock::Create(C, "then", F);
-  BranchInst::Create(If1, Else1, UndefValue::get(I1Ty), Entry);
+  BranchInst::Create(If1, Else1, PoisonValue::get(I1Ty), Entry);
   BranchInst::Create(Then, If1);
   BranchInst::Create(Then, Else1);
-  BranchInst::Create(If2, Else2, UndefValue::get(I1Ty), Then);
+  BranchInst::Create(If2, Else2, PoisonValue::get(I1Ty), Then);
   BranchInst::Create(End, If2);
   BranchInst::Create(End, Else2);
 
-  Value *Val1 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val1", Entry);
-  Value *Val2 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val2", Entry);
-  Value *Val3 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val3", Entry);
-  Value *Val4 = new LoadInst(I32Ty, UndefValue::get(PtrTy), "val4", Entry);
+  Value *Val1 = new LoadInst(I32Ty, PoisonValue::get(PtrTy), "val1", Entry);
+  Value *Val2 = new LoadInst(I32Ty, PoisonValue::get(PtrTy), "val2", Entry);
+  Value *Val3 = new LoadInst(I32Ty, PoisonValue::get(PtrTy), "val3", Entry);
+  Value *Val4 = new LoadInst(I32Ty, PoisonValue::get(PtrTy), "val4", Entry);
 
   PHINode *Phi1 = PHINode::Create(I32Ty, 2, "phi1", Then);
   Phi1->addIncoming(Val1, If1);

@leewei05 leewei05 changed the title Replace UndefValue::get with PoisonValue::get in unit test [llvm] Replace UndefValue::get with PoisonValue::get in unit test Nov 13, 2024
@leewei05 leewei05 force-pushed the remove-undef-get-unittest branch from 44fe8eb to 744bd01 Compare November 13, 2024 04:16
@nunoplopes nunoplopes merged commit 91e134a into llvm:main Nov 13, 2024
8 checks passed
@leewei05 leewei05 deleted the remove-undef-get-unittest branch November 13, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:analysis Includes value tracking, cost tables and constant folding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants