[llvm] 78e1f70 - [ObjCARCOpts] Use standard non-terminator unreachable pattern
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 25 04:10:10 PST 2022
Author: Nikita Popov
Date: 2022-01-25T13:08:03+01:00
New Revision: 78e1f70220a57bc7a7554d4240c5f15810959d7c
URL: https://github.com/llvm/llvm-project/commit/78e1f70220a57bc7a7554d4240c5f15810959d7c
DIFF: https://github.com/llvm/llvm-project/commit/78e1f70220a57bc7a7554d4240c5f15810959d7c.diff
LOG: [ObjCARCOpts] Use standard non-terminator unreachable pattern
This is what CreateNonTerminatorUnreachable() in InstCombine uses.
Specific choice here doesn't really matter, but we should pick
one that is pointer element type independent.
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 caad91867112c..b6dc97f1e43f8 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -979,9 +979,8 @@ void ObjCARCOpt::OptimizeIndividualCallImpl(
CallInst *CI = cast<CallInst>(Inst);
if (IsNullOrUndef(CI->getArgOperand(0))) {
Changed = true;
- Type *Ty = CI->getArgOperand(0)->getType();
- new StoreInst(UndefValue::get(Ty->getPointerElementType()),
- Constant::getNullValue(Ty), CI);
+ new StoreInst(ConstantInt::getTrue(CI->getContext()),
+ UndefValue::get(Type::getInt1PtrTy(CI->getContext())), CI);
Value *NewValue = UndefValue::get(CI->getType());
LLVM_DEBUG(
dbgs() << "A null pointer-to-weak-pointer is undefined behavior."
@@ -999,9 +998,8 @@ void ObjCARCOpt::OptimizeIndividualCallImpl(
if (IsNullOrUndef(CI->getArgOperand(0)) ||
IsNullOrUndef(CI->getArgOperand(1))) {
Changed = true;
- Type *Ty = CI->getArgOperand(0)->getType();
- new StoreInst(UndefValue::get(Ty->getPointerElementType()),
- Constant::getNullValue(Ty), CI);
+ new StoreInst(ConstantInt::getTrue(CI->getContext()),
+ UndefValue::get(Type::getInt1PtrTy(CI->getContext())), CI);
Value *NewValue = UndefValue::get(CI->getType());
LLVM_DEBUG(
diff --git a/llvm/test/Transforms/ObjCARC/weak.ll b/llvm/test/Transforms/ObjCARC/weak.ll
index 2009addbbdc56..00a4e9f681e7d 100644
--- a/llvm/test/Transforms/ObjCARC/weak.ll
+++ b/llvm/test/Transforms/ObjCARC/weak.ll
@@ -14,24 +14,24 @@ declare void @llvm.objc.copyWeak(i8**, i8**)
define void @test0(i8* %p, i8** %q) {
; CHECK-LABEL: @test0(
; CHECK-NEXT: entry:
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
-; CHECK-NEXT: store i8* undef, i8** null, align 8
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
+; CHECK-NEXT: store i1 true, i1* undef, align 1
; CHECK-NEXT: ret void
;
entry:
More information about the llvm-commits
mailing list