aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/GVN.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2007-12-01 07:51:45 +0000
committerDuncan Sands <baldrick@free.fr>2007-12-01 07:51:45 +0000
commitdff6710717b159f089c76a07eda074eb6347eb92 (patch)
tree7bbd754ebe64f5d4bbc6000e0e66bdd99f9c847f /lib/Transforms/Scalar/GVN.cpp
parente3110d0825e6316fd2dd21d6a4e593295cd413f1 (diff)
Integrate the readonly/readnone logic more deeply
into alias analysis. This meant updating the API which now has versions of the getModRefBehavior, doesNotAccessMemory and onlyReadsMemory methods which take a callsite parameter. These should be used unless the callsite is not known, since in general they can do a better job than the versions that take a function. Also, users should no longer call the version of getModRefBehavior that takes both a function and a callsite. To reduce the chance of misuse it is now protected. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44487 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/GVN.cpp')
-rw-r--r--lib/Transforms/Scalar/GVN.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 7799befb3c..c3d59854c6 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -341,8 +341,7 @@ Expression::ExpressionOpcode
uint32_t ValueTable::hash_operand(Value* v) {
if (CallInst* CI = dyn_cast<CallInst>(v))
- if (CI->getCalledFunction() &&
- !AA->doesNotAccessMemory(CI->getCalledFunction()))
+ if (!AA->doesNotAccessMemory(CI))
return nextValueNumber++;
return lookup_or_add(v);
@@ -485,9 +484,7 @@ uint32_t ValueTable::lookup_or_add(Value* V) {
return VI->second;
if (CallInst* C = dyn_cast<CallInst>(V)) {
- if (C->getCalledFunction() &&
- (AA->doesNotAccessMemory(C->getCalledFunction()) ||
- AA->onlyReadsMemory(C->getCalledFunction()))) {
+ if (AA->onlyReadsMemory(C)) { // includes doesNotAccessMemory
Expression e = create_expression(C);
DenseMap<Expression, uint32_t>::iterator EI = expressionNumbering.find(e);
@@ -1051,8 +1048,7 @@ bool GVN::processInstruction(Instruction* I,
if (CallInst* CI = dyn_cast<CallInst>(I)) {
AliasAnalysis& AA = getAnalysis<AliasAnalysis>();
- if (CI->getCalledFunction() &&
- !AA.doesNotAccessMemory(CI->getCalledFunction())) {
+ if (!AA.doesNotAccessMemory(CI)) {
MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>();
if (cast<Instruction>(repl)->getParent() != CI->getParent() ||
MD.getDependency(CI) != MD.getDependency(cast<CallInst>(repl))) {