aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2016-01-06 04:53:16 +0000
committerPhilip Reames <listmail@philipreames.com>2016-01-06 04:53:16 +0000
commitae050a570317ac8504bdd31fa73b52100471d753 (patch)
treedf777a986dd43b27d36d9c1fbc8facc42f5d5589 /llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp
parentcdf46d1b52e976bdad3d383cdec0989cc9747c83 (diff)
downloadllvm-ae050a570317ac8504bdd31fa73b52100471d753.zip
llvm-ae050a570317ac8504bdd31fa73b52100471d753.tar.gz
llvm-ae050a570317ac8504bdd31fa73b52100471d753.tar.bz2
[BasicAA] Remove special casing of memset_pattern16 in favor of generic attribute inference
Most of the properties of memset_pattern16 can be now covered by the generic attributes and inferred by InferFunctionAttrs. The only exceptions are: - We don't yet have a writeonly attribute for the first argument. - We don't have an attribute for modeling the access size facts encoded in MemoryLocation.cpp. Differential Revision: http://reviews.llvm.org/D15879 llvm-svn: 256911
Diffstat (limited to 'llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp b/llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp
index 0f0182e..4295a75 100644
--- a/llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp
@@ -22,6 +22,7 @@ using namespace llvm;
STATISTIC(NumReadNone, "Number of functions inferred as readnone");
STATISTIC(NumReadOnly, "Number of functions inferred as readonly");
+STATISTIC(NumArgMemOnly, "Number of functions inferred as argmemonly");
STATISTIC(NumNoUnwind, "Number of functions inferred as nounwind");
STATISTIC(NumNoCapture, "Number of arguments inferred as nocapture");
STATISTIC(NumReadOnlyArg, "Number of arguments inferred as readonly");
@@ -44,6 +45,15 @@ static bool setOnlyReadsMemory(Function &F) {
return true;
}
+static bool setOnlyAccessesArgMemory(Function &F) {
+ if (F.onlyAccessesArgMemory())
+ return false;
+ F.setOnlyAccessesArgMemory ();
+ ++NumArgMemOnly;
+ return true;
+}
+
+
static bool setDoesNotThrow(Function &F) {
if (F.doesNotThrow())
return false;
@@ -900,6 +910,20 @@ static bool inferPrototypeAttributes(Function &F,
Changed |= setDoesNotAlias(F, AttributeSet::ReturnIndex);
return Changed;
+ //TODO: add LibFunc entries for:
+ //case LibFunc::memset_pattern4:
+ //case LibFunc::memset_pattern8:
+ case LibFunc::memset_pattern16:
+ if (FTy->isVarArg() || FTy->getNumParams() != 3 ||
+ !isa<PointerType>(FTy->getParamType(0)) ||
+ !isa<PointerType>(FTy->getParamType(1)) ||
+ !isa<IntegerType>(FTy->getParamType(2)))
+ return false;
+
+ Changed |= setOnlyAccessesArgMemory(F);
+ Changed |= setOnlyReadsMemory(F, 2);
+ return Changed;
+
default:
// FIXME: It'd be really nice to cover all the library functions we're
// aware of here.