aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-02-17 21:29:08 +0000
committerOwen Anderson <resistor@mac.com>2008-02-17 21:29:08 +0000
commit9b636cb3385376faa7f33a943cac7d40bff1531a (patch)
tree1a1a1a651e5f99a457c7c787c568e8530aecc352 /lib/Analysis
parentdd12f96c5e2292e398f363cf352d6a95847a8a55 (diff)
downloadexternal_llvm-9b636cb3385376faa7f33a943cac7d40bff1531a.zip
external_llvm-9b636cb3385376faa7f33a943cac7d40bff1531a.tar.gz
external_llvm-9b636cb3385376faa7f33a943cac7d40bff1531a.tar.bz2
Teach getModRefInfo that memcpy, memmove, and memset don't "capture" memory addresses.
Also, noalias arguments are be considered "like" stack allocated ones for this purpose, because the only way they can be modref'ed is if they escape somewhere in the current function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47247 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index be8fe07..430e74a 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -21,7 +21,7 @@
#include "llvm/ParameterAttributes.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Instructions.h"
-#include "llvm/Intrinsics.h"
+#include "llvm/IntrinsicInst.h"
#include "llvm/Pass.h"
#include "llvm/Target/TargetData.h"
#include "llvm/ADT/SmallVector.h"
@@ -228,6 +228,13 @@ static bool AddressMightEscape(const Value *V) {
// If returned, the address will escape to calling functions, but no
// 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
+ if (isa<MemIntrinsic>(I))
+ return false;
+ else
+ return true;
default:
return true;
}
@@ -247,8 +254,11 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
// Allocations and byval arguments are "new" objects.
if (Object &&
(isa<AllocationInst>(Object) ||
- (isa<Argument>(Object) && cast<Argument>(Object)->hasByValAttr()))) {
- // Okay, the pointer is to a stack allocated object. If we can prove that
+ (isa<Argument>(Object) &&
+ (cast<Argument>(Object)->hasByValAttr() ||
+ cast<Argument>(Object)->hasNoAliasAttr())))) {
+ // Okay, the pointer is to a stack allocated (or effectively so, for
+ // for noalias parameters) object. If we can prove that
// the pointer never "escapes", then we know the call cannot clobber it,
// because it simply can't get its address.
if (!AddressMightEscape(Object))