Author: rnk Date: Tue Aug 14 10:35:35 2018 New Revision: 339698 URL: http://llvm.org/viewvc/llvm-project?rev=339698&view=rev Log: Merging r339636: ------------------------------------------------------------------------ r339636 | rnk | 2018-08-13 18:24:35 -0700 (Mon, 13 Aug 2018) | 17 lines
[BasicAA] Don't assume tail calls with byval don't alias allocas Summary: Calls marked 'tail' cannot read or write allocas from the current frame because the current frame might be destroyed by the time they run. However, a tail call may use an alloca with byval. Calling with byval copies the contents of the alloca into argument registers or stack slots, so there is no lifetime issue. Tail calls never modify allocas, so we can return just ModRefInfo::Ref. Fixes PR38466, a longstanding bug. Reviewers: hfinkel, nlewycky, gbiv, george.burgess.iv Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D50679 ------------------------------------------------------------------------ Added: llvm/branches/release_70/test/Analysis/BasicAA/tail-byval.ll - copied unchanged from r339636, llvm/trunk/test/Analysis/BasicAA/tail-byval.ll llvm/branches/release_70/test/Transforms/DeadStoreElimination/tail-byval.ll - copied unchanged from r339636, llvm/trunk/test/Transforms/DeadStoreElimination/tail-byval.ll Modified: llvm/branches/release_70/ (props changed) llvm/branches/release_70/lib/Analysis/BasicAliasAnalysis.cpp Propchange: llvm/branches/release_70/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Aug 14 10:35:35 2018 @@ -1,3 +1,3 @@ /llvm/branches/Apple/Pertwee:110850,110961 /llvm/branches/type-system-rewrite:133420-134817 -/llvm/trunk:155241,338552,338554,338569,338599,338610,338658,338665,338682,338703,338709,338716,338751,338762,338817,338902,338915,338968,339073,339179,339184,339190,339225,339316,339319,339411,339492,339600 +/llvm/trunk:155241,338552,338554,338569,338599,338610,338658,338665,338682,338703,338709,338716,338751,338762,338817,338902,338915,338968,339073,339179,339184,339190,339225,339316,339319,339411,339492,339600,339636 Modified: llvm/branches/release_70/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_70/lib/Analysis/BasicAliasAnalysis.cpp?rev=339698&r1=339697&r2=339698&view=diff ============================================================================== --- llvm/branches/release_70/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/branches/release_70/lib/Analysis/BasicAliasAnalysis.cpp Tue Aug 14 10:35:35 2018 @@ -801,14 +801,15 @@ ModRefInfo BasicAAResult::getModRefInfo( const Value *Object = GetUnderlyingObject(Loc.Ptr, DL); - // If this is a tail call and Loc.Ptr points to a stack location, we know that - // the tail call cannot access or modify the local stack. - // We cannot exclude byval arguments here; these belong to the caller of - // the current function not to the current function, and a tail callee - // may reference them. + // Calls marked 'tail' cannot read or write allocas from the current frame + // because the current frame might be destroyed by the time they run. However, + // a tail call may use an alloca with byval. Calling with byval copies the + // contents of the alloca into argument registers or stack slots, so there is + // no lifetime issue. if (isa<AllocaInst>(Object)) if (const CallInst *CI = dyn_cast<CallInst>(CS.getInstruction())) - if (CI->isTailCall()) + if (CI->isTailCall() && + !CI->getAttributes().hasAttrSomewhere(Attribute::ByVal)) return ModRefInfo::NoModRef; // If the pointer is to a locally allocated object that does not escape, _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits