Skip to content

Commit

Permalink
[ObjCARCOpts] Use standard non-terminator unreachable pattern
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Jan 25, 2022
1 parent 4f4d071 commit 78e1f70
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
10 changes: 4 additions & 6 deletions llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
Expand Up @@ -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."
Expand All @@ -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(
Expand Down
36 changes: 18 additions & 18 deletions llvm/test/Transforms/ObjCARC/weak.ll
Expand Up @@ -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:
Expand Down

0 comments on commit 78e1f70

Please sign in to comment.