From 2abb108f1b92ffa60dd8a89d3c90eddabb5ea76f Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 19 Dec 2008 06:39:12 +0000 Subject: Resubmit support for the 'nocapture' attribute. The problematic part of this patch is that we were out of attribute bits, requiring some fancy bit hacking to make it fit (by shrinking alignment) without breaking existing users or the file format. This change will require users to rebuild llvm-gcc to match llvm. llvm-svn: 61239 --- llvm/lib/Analysis/BasicAliasAnalysis.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp') diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 3270f35ac41..57d320971db 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -63,12 +63,23 @@ static bool AddressMightEscape(const Value *V) { // callees could modify it. break; // next use case Instruction::Call: - // If the call is to a few known safe intrinsics, we know that it does - // not escape. - // TODO: Eventually just check the 'nocapture' attribute. - if (!isa(I)) - return true; - break; // next use + // If the argument to the call has the nocapture attribute, then the call + // may store or load to the pointer, but it cannot escape. + if (cast(I)->paramHasAttr(UI.getOperandNo(), + Attribute::NoCapture)) + continue; + + // FIXME: MemIntrinsics should have their operands marked nocapture! + if (isa(I)) + continue; // next use + return true; + case Instruction::Invoke: + // If the argument to the call has the nocapture attribute, then the call + // may store or load to the pointer, but it cannot escape. + if (cast(I)->paramHasAttr(UI.getOperandNo()-2, + Attribute::NoCapture)) + continue; + return true; default: return true; } -- cgit v1.2.3