summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2016-01-27 19:05:08 +0000
committerJohn McCall <rjmccall@apple.com>2016-01-27 19:05:08 +0000
commit3fe604f89fccfe1534eeaf4b4e328185d01659f6 (patch)
treea5113ad2639cc50d9a0a3f68f993f3d26d634ccf /llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
parent671e6340da589fe94d30fa97fb3c89318881a775 (diff)
downloadbcm5719-llvm-3fe604f89fccfe1534eeaf4b4e328185d01659f6.tar.gz
bcm5719-llvm-3fe604f89fccfe1534eeaf4b4e328185d01659f6.zip
Add support for objc_unsafeClaimAutoreleasedReturnValue to the
ObjC ARC Optimizer. The main implication of this is: 1. Ensuring that we treat it conservatively in terms of optimization. 2. We put the ASM marker on it so that the runtime can recognize objc_unsafeClaimAutoreleasedReturnValue from releaseRV. <rdar://problem/21567064> Patch by Michael Gottesman! llvm-svn: 258970
Diffstat (limited to 'llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp')
-rw-r--r--llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
index 1cdf5689f42..edef360be61 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
@@ -66,7 +66,7 @@ namespace {
/// The inline asm string to insert between calls and RetainRV calls to make
/// the optimization work on targets which need it.
- const MDString *RetainRVMarker;
+ const MDString *RVInstMarker;
/// The set of inserted objc_storeStrong calls. If at the end of walking the
/// function we have found no alloca instructions, these calls can be marked
@@ -423,16 +423,16 @@ bool ObjCARCContract::tryToPeepholeInstruction(
return false;
// If we succeed in our optimization, fall through.
// FALLTHROUGH
- case ARCInstKind::RetainRV: {
+ case ARCInstKind::RetainRV:
+ case ARCInstKind::ClaimRV: {
// If we're compiling for a target which needs a special inline-asm
- // marker to do the retainAutoreleasedReturnValue optimization,
- // insert it now.
- if (!RetainRVMarker)
+ // marker to do the return value optimization, insert it now.
+ if (!RVInstMarker)
return false;
BasicBlock::iterator BBI = Inst->getIterator();
BasicBlock *InstParent = Inst->getParent();
- // Step up to see if the call immediately precedes the RetainRV call.
+ // Step up to see if the call immediately precedes the RV call.
// If it's an invoke, we have to cross a block boundary. And we have
// to carefully dodge no-op instructions.
do {
@@ -447,14 +447,14 @@ bool ObjCARCContract::tryToPeepholeInstruction(
} while (IsNoopInstruction(&*BBI));
if (&*BBI == GetArgRCIdentityRoot(Inst)) {
- DEBUG(dbgs() << "Adding inline asm marker for "
- "retainAutoreleasedReturnValue optimization.\n");
+ DEBUG(dbgs() << "Adding inline asm marker for the return value "
+ "optimization.\n");
Changed = true;
- InlineAsm *IA =
- InlineAsm::get(FunctionType::get(Type::getVoidTy(Inst->getContext()),
- /*isVarArg=*/false),
- RetainRVMarker->getString(),
- /*Constraints=*/"", /*hasSideEffects=*/true);
+ InlineAsm *IA = InlineAsm::get(
+ FunctionType::get(Type::getVoidTy(Inst->getContext()),
+ /*isVarArg=*/false),
+ RVInstMarker->getString(),
+ /*Constraints=*/"", /*hasSideEffects=*/true);
CallInst::Create(IA, "", Inst);
}
decline_rv_optimization:
@@ -650,15 +650,15 @@ bool ObjCARCContract::doInitialization(Module &M) {
EP.init(&M);
- // Initialize RetainRVMarker.
- RetainRVMarker = nullptr;
+ // Initialize RVInstMarker.
+ RVInstMarker = nullptr;
if (NamedMDNode *NMD =
M.getNamedMetadata("clang.arc.retainAutoreleasedReturnValueMarker"))
if (NMD->getNumOperands() == 1) {
const MDNode *N = NMD->getOperand(0);
if (N->getNumOperands() == 1)
if (const MDString *S = dyn_cast<MDString>(N->getOperand(0)))
- RetainRVMarker = S;
+ RVInstMarker = S;
}
return false;
OpenPOWER on IntegriCloud