diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2017-10-16 16:46:59 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2017-10-16 16:46:59 +0000 |
commit | e8c1a54c07b7594e4057c76a57cadbcb0b1544a3 (patch) | |
tree | e7779cb6ac9a0c76b7a4cbb0b8b5fa0c77c47e7d /llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp | |
parent | a4b89ed0b764e2a2e5cf2cea0519d6f191425307 (diff) | |
download | bcm5719-llvm-e8c1a54c07b7594e4057c76a57cadbcb0b1544a3.tar.gz bcm5719-llvm-e8c1a54c07b7594e4057c76a57cadbcb0b1544a3.zip |
[ObjCARC] Do not move a release that has the clang.imprecise_release tag
above PHI instructions.
ARC optimizer has an optimization that moves a call to an ObjC runtime
function above a phi instruction when the phi has a null operand and is
an argument passed to the function call. This optimization should not
kick in when the runtime function is an objc_release that releases an
object with precise lifetime semantics.
rdar://problem/34959669
llvm-svn: 315914
Diffstat (limited to 'llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp')
-rw-r--r-- | llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp index 8c0a90843ef..6692d950da2 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -808,9 +808,14 @@ void ObjCARCOpt::OptimizeIndividualCalls(Function &F) { // If Arg is a PHI, and one or more incoming values to the // PHI are null, and the call is control-equivalent to the PHI, and there - // are no relevant side effects between the PHI and the call, the call - // could be pushed up to just those paths with non-null incoming values. - // For now, don't bother splitting critical edges for this. + // are no relevant side effects between the PHI and the call, and the call + // is not a release that doesn't have the clang.imprecise_release tag, the + // call could be pushed up to just those paths with non-null incoming + // values. For now, don't bother splitting critical edges for this. + if (Class == ARCInstKind::Release && + !Inst->getMetadata(MDKindCache.get(ARCMDKindID::ImpreciseRelease))) + continue; + SmallVector<std::pair<Instruction *, const Value *>, 4> Worklist; Worklist.push_back(std::make_pair(Inst, Arg)); do { |