Author: Akira Hatanaka Date: 2021-06-29T10:23:01-07:00 New Revision: 952944c12c0aa917e97805e929b5cd4e40866f91
URL: https://github.com/llvm/llvm-project/commit/952944c12c0aa917e97805e929b5cd4e40866f91 DIFF: https://github.com/llvm/llvm-project/commit/952944c12c0aa917e97805e929b5cd4e40866f91.diff LOG: [ObjC][ARC] Don't add operand bundle clang.arc.attachedcall to a call if the call already has the operand bundle This bug was causing the call to `replaceAllUsesWith` to crash because the old call instruction and the new call instruction were the same. rdar://74957948 Differential Revision: https://reviews.llvm.org/D97824 Added: clang/test/CodeGenObjCXX/arc-rv-attr.mm Modified: clang/lib/CodeGen/CGObjC.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 6c36dde1f526d..63429b1d4f653 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -2939,8 +2939,12 @@ static llvm::Value *emitARCOperationAfterCall(CodeGenFunction &CGF, ValueTransform doAfterCall, ValueTransform doFallback) { CGBuilderTy::InsertPoint ip = CGF.Builder.saveIP(); + auto *callBase = dyn_cast<llvm::CallBase>(value); - if (llvm::CallInst *call = dyn_cast<llvm::CallInst>(value)) { + if (callBase && llvm::objcarc::hasAttachedCallOpBundle(callBase)) { + // Fall back if the call base has operand bundle "clang.arc.attachedcall". + value = doFallback(CGF, value); + } else if (llvm::CallInst *call = dyn_cast<llvm::CallInst>(value)) { // Place the retain immediately following the call. CGF.Builder.SetInsertPoint(call->getParent(), ++llvm::BasicBlock::iterator(call)); diff --git a/clang/test/CodeGenObjCXX/arc-rv-attr.mm b/clang/test/CodeGenObjCXX/arc-rv-attr.mm new file mode 100644 index 0000000000000..0f4519bd527d9 --- /dev/null +++ b/clang/test/CodeGenObjCXX/arc-rv-attr.mm @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios9 -fobjc-runtime=ios-9.0 -fobjc-arc -std=c++11 -O -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK + +id foo(void); + +// CHECK-LABEL: define{{.*}} void @_Z14test_list_initv( +// CHECK: %[[CALL1:.*]] = call i8* @_Z3foov() [ "clang.arc.attachedcall"(i64 0) ] +// CHECK: call i8* @llvm.objc.retain(i8* %[[CALL1]]) + +void test_list_init() { + auto t = id{foo()}; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits