summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-11-08 17:12:04 +0000
committerDan Gohman <gohman@apple.com>2010-11-08 17:12:04 +0000
commit2cd1fd4a828812e3b45b5144ae8cb7ce950792cd (patch)
treed4ceb6ff841f5c124f4d17441ca610973e1e6818 /llvm/lib/Transforms/IPO/FunctionAttrs.cpp
parent601c94b309a13460aae314fdce8a8b24bb10712e (diff)
downloadbcm5719-llvm-2cd1fd4a828812e3b45b5144ae8cb7ce950792cd.tar.gz
bcm5719-llvm-2cd1fd4a828812e3b45b5144ae8cb7ce950792cd.zip
Make FunctionAttrs TBAA-aware.
llvm-svn: 118417
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionAttrs.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionAttrs.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index be5d827e8e5..c4978b4df56 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -23,6 +23,7 @@
#include "llvm/CallGraphSCCPass.h"
#include "llvm/GlobalVariable.h"
#include "llvm/IntrinsicInst.h"
+#include "llvm/LLVMContext.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/CaptureTracking.h"
@@ -140,10 +141,14 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
CI != CE; ++CI) {
Value *Arg = *CI;
- if (Arg->getType()->isPointerTy() &&
- !AA->pointsToConstantMemory(Arg, /*OrLocal=*/true))
- // Writes memory. Just give up.
- return false;
+ if (Arg->getType()->isPointerTy()) {
+ AliasAnalysis::Location Loc(Arg,
+ AliasAnalysis::UnknownSize,
+ I->getMetadata(LLVMContext::MD_tbaa));
+ if (!AA->pointsToConstantMemory(Arg, /*OrLocal=*/true))
+ // Writes memory. Just give up.
+ return false;
+ }
}
// Only reads and writes local memory.
continue;
@@ -153,16 +158,23 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
}
} else if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
// Ignore non-volatile loads from local memory.
- if (!LI->isVolatile() &&
- AA->pointsToConstantMemory(LI->getPointerOperand(),
- /*OrLocal=*/true))
- continue;
+ if (!LI->isVolatile()) {
+ AliasAnalysis::Location Loc(LI->getPointerOperand(),
+ AA->getTypeStoreSize(LI->getType()),
+ LI->getMetadata(LLVMContext::MD_tbaa));
+ if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
+ continue;
+ }
} else if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
// Ignore non-volatile stores to local memory.
- if (!SI->isVolatile() &&
- AA->pointsToConstantMemory(SI->getPointerOperand(),
- /*OrLocal=*/true))
- continue;
+ if (!SI->isVolatile()) {
+ const Type *StoredType = SI->getValueOperand()->getType();
+ AliasAnalysis::Location Loc(SI->getPointerOperand(),
+ AA->getTypeStoreSize(StoredType),
+ SI->getMetadata(LLVMContext::MD_tbaa));
+ if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
+ continue;
+ }
}
// Any remaining instructions need to be taken seriously! Check if they
OpenPOWER on IntegriCloud