aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-17 07:40:34 +0000
committerChris Lattner <sabre@nondot.org>2004-07-17 07:40:34 +0000
commitcb19d679076724a86b62a1821e422ad69ab3d9c5 (patch)
tree1ee424fbdc13f49c64ce76f4f11fae47bd557582 /lib/Analysis
parentad48cc71dcd218216e5e7df6d05c481946a65879 (diff)
downloadexternal_llvm-cb19d679076724a86b62a1821e422ad69ab3d9c5.zip
external_llvm-cb19d679076724a86b62a1821e422ad69ab3d9c5.tar.gz
external_llvm-cb19d679076724a86b62a1821e422ad69ab3d9c5.tar.bz2
Fix incorrect computation of mod/ref sets. Do not ask for mod/ref information
for objects of size 0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14908 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/AliasAnalysisEvaluator.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp
index f3b4eba..2794fef 100644
--- a/lib/Analysis/AliasAnalysisEvaluator.cpp
+++ b/lib/Analysis/AliasAnalysisEvaluator.cpp
@@ -21,7 +21,7 @@
#include "llvm/iOther.h"
#include "llvm/iTerminators.h"
#include "llvm/Pass.h"
-#include "llvm/Type.h"
+#include "llvm/DerivedTypes.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/InstIterator.h"
@@ -137,27 +137,35 @@ bool AAEval::runOnFunction(Function &F) {
// Mod/ref alias analysis: compare all pairs of calls and values
for (std::set<Value *>::iterator V = Pointers.begin(), Ve = Pointers.end();
- V != Ve; ++V)
- for (std::set<CallSite>::iterator C = CallSites.begin(),
- Ce = CallSites.end(); C != Ce; ++C) {
- Instruction *I = C->getInstruction();
- switch (AA.getModRefInfo(*C, *V, (*V)->getType()->getPrimitiveSize())) {
- case AliasAnalysis::NoModRef:
- PrintModRefResults("NoModRef", PrintNoModRef, I, *V, F.getParent());
- ++NoModRef; break;
- case AliasAnalysis::Mod:
- PrintModRefResults(" Mod", PrintMod, I, *V, F.getParent());
- ++Mod; break;
- case AliasAnalysis::Ref:
- PrintModRefResults(" Ref", PrintRef, I, *V, F.getParent());
- ++Ref; break;
- case AliasAnalysis::ModRef:
- PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent());
- ++ModRef; break;
- default:
- std::cerr << "Unknown alias query result!\n";
+ V != Ve; ++V) {
+ unsigned Size = 0;
+ if (const PointerType *PTy = dyn_cast<PointerType>((*V)->getType()))
+ if (!(Size = PTy->getElementType()->getPrimitiveSize()))
+ if (isa<PointerType>(PTy->getElementType()))
+ Size = 4; // This is a hack, but it's good enough for eval.
+
+ if (Size)
+ for (std::set<CallSite>::iterator C = CallSites.begin(),
+ Ce = CallSites.end(); C != Ce; ++C) {
+ Instruction *I = C->getInstruction();
+ switch (AA.getModRefInfo(*C, *V, Size)) {
+ case AliasAnalysis::NoModRef:
+ PrintModRefResults("NoModRef", PrintNoModRef, I, *V, F.getParent());
+ ++NoModRef; break;
+ case AliasAnalysis::Mod:
+ PrintModRefResults(" Mod", PrintMod, I, *V, F.getParent());
+ ++Mod; break;
+ case AliasAnalysis::Ref:
+ PrintModRefResults(" Ref", PrintRef, I, *V, F.getParent());
+ ++Ref; break;
+ case AliasAnalysis::ModRef:
+ PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent());
+ ++ModRef; break;
+ default:
+ std::cerr << "Unknown alias query result!\n";
+ }
}
- }
+ }
return false;
}