[llvm] b396817 - [ObjCARC] Use poison instead of undef as placeholder [NFC]
Nuno Lopes via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 22 14:41:30 PDT 2023
Author: Nuno Lopes
Date: 2023-07-22T22:41:24+01:00
New Revision: b396817c61cd07cfa31b5f74998b8448bfdeb07f
URL: https://github.com/llvm/llvm-project/commit/b396817c61cd07cfa31b5f74998b8448bfdeb07f
DIFF: https://github.com/llvm/llvm-project/commit/b396817c61cd07cfa31b5f74998b8448bfdeb07f.diff
LOG: [ObjCARC] Use poison instead of undef as placeholder [NFC]
It's used to specify UB (as ptr argument to store) and to RAUW values when UB occurs.
Added:
Modified:
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/test/Transforms/ObjCARC/weak.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index 0d17ef773f44c6..adf86526ebf14c 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -933,8 +933,8 @@ void ObjCARCOpt::OptimizeIndividualCallImpl(Function &F, Instruction *Inst,
if (IsNullOrUndef(CI->getArgOperand(0))) {
Changed = true;
new StoreInst(ConstantInt::getTrue(CI->getContext()),
- UndefValue::get(Type::getInt1PtrTy(CI->getContext())), CI);
- Value *NewValue = UndefValue::get(CI->getType());
+ PoisonValue::get(Type::getInt1PtrTy(CI->getContext())), CI);
+ Value *NewValue = PoisonValue::get(CI->getType());
LLVM_DEBUG(
dbgs() << "A null pointer-to-weak-pointer is undefined behavior."
"\nOld = "
@@ -952,9 +952,9 @@ void ObjCARCOpt::OptimizeIndividualCallImpl(Function &F, Instruction *Inst,
IsNullOrUndef(CI->getArgOperand(1))) {
Changed = true;
new StoreInst(ConstantInt::getTrue(CI->getContext()),
- UndefValue::get(Type::getInt1PtrTy(CI->getContext())), CI);
+ PoisonValue::get(Type::getInt1PtrTy(CI->getContext())), CI);
- Value *NewValue = UndefValue::get(CI->getType());
+ Value *NewValue = PoisonValue::get(CI->getType());
LLVM_DEBUG(
dbgs() << "A null pointer-to-weak-pointer is undefined behavior."
"\nOld = "
diff --git a/llvm/test/Transforms/ObjCARC/weak.ll b/llvm/test/Transforms/ObjCARC/weak.ll
index ad5ac571f06ca7..db63847c8f6c9f 100644
--- a/llvm/test/Transforms/ObjCARC/weak.ll
+++ b/llvm/test/Transforms/ObjCARC/weak.ll
@@ -14,24 +14,24 @@ declare void @llvm.objc.copyWeak(ptr, ptr)
define void @test0(ptr %p, ptr %q) {
; CHECK-LABEL: @test0(
; CHECK-NEXT: entry:
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
-; CHECK-NEXT: store i1 true, ptr undef, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
+; CHECK-NEXT: store i1 true, ptr poison, align 1
; CHECK-NEXT: ret void
;
entry:
More information about the llvm-commits
mailing list