summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-12-19 06:39:12 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-12-19 06:39:12 +0000
commit2abb108f1b92ffa60dd8a89d3c90eddabb5ea76f (patch)
treef05e6d0ee2d6177814d1d3197b1a8bd8d56dd947 /llvm/lib/Analysis/BasicAliasAnalysis.cpp
parent19a54ffc7f955c5b322abce63fdf06c7dc2bd42e (diff)
downloadbcm5719-llvm-2abb108f1b92ffa60dd8a89d3c90eddabb5ea76f.tar.gz
bcm5719-llvm-2abb108f1b92ffa60dd8a89d3c90eddabb5ea76f.zip
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
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/BasicAliasAnalysis.cpp23
1 files changed, 17 insertions, 6 deletions
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<MemIntrinsic>(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<CallInst>(I)->paramHasAttr(UI.getOperandNo(),
+ Attribute::NoCapture))
+ continue;
+
+ // FIXME: MemIntrinsics should have their operands marked nocapture!
+ if (isa<MemIntrinsic>(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<InvokeInst>(I)->paramHasAttr(UI.getOperandNo()-2,
+ Attribute::NoCapture))
+ continue;
+ return true;
default:
return true;
}
OpenPOWER on IntegriCloud