#include "llvm/Type.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Assembly/Writer.h"
-#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/InstIterator.h"
-#include "llvm/Support/Streams.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
/// mergeSetIn - Merge the specified alias set into this alias set.
// Check the call sites list and invoke list...
if (!CallSites.empty()) {
- if (AA.hasNoModRefInfoForCalls())
- return true;
-
for (unsigned i = 0, e = CallSites.size(); i != e; ++i)
if (AA.getModRefInfo(CallSites[i], const_cast<Value*>(Ptr), Size)
!= AliasAnalysis::NoModRef)
if (AA.doesNotAccessMemory(CS))
return false;
- if (AA.hasNoModRefInfoForCalls())
- return true;
-
for (unsigned i = 0, e = CallSites.size(); i != e; ++i)
if (AA.getModRefInfo(CallSites[i], CS) != AliasAnalysis::NoModRef ||
AA.getModRefInfo(CS, CallSites[i]) != AliasAnalysis::NoModRef)
return NewPtr;
}
-bool AliasSetTracker::add(FreeInst *FI) {
- bool NewPtr;
- addPointer(FI->getOperand(0), ~0, AliasSet::Mods, NewPtr);
- return NewPtr;
-}
-
bool AliasSetTracker::add(VAArgInst *VAAI) {
bool NewPtr;
addPointer(VAAI->getOperand(0), ~0, AliasSet::ModRef, NewPtr);
return add(CI);
else if (InvokeInst *II = dyn_cast<InvokeInst>(I))
return add(II);
- else if (FreeInst *FI = dyn_cast<FreeInst>(I))
- return add(FI);
else if (VAArgInst *VAAI = dyn_cast<VAArgInst>(I))
return add(VAAI);
return true;
return true;
}
-bool AliasSetTracker::remove(FreeInst *FI) {
- AliasSet *AS = findAliasSetForPointer(FI->getOperand(0), ~0);
- if (!AS) return false;
- remove(*AS);
- return true;
-}
-
bool AliasSetTracker::remove(VAArgInst *VAAI) {
AliasSet *AS = findAliasSetForPointer(VAAI->getOperand(0), ~0);
if (!AS) return false;
return remove(SI);
else if (CallInst *CI = dyn_cast<CallInst>(I))
return remove(CI);
- else if (FreeInst *FI = dyn_cast<FreeInst>(I))
- return remove(FI);
else if (VAArgInst *VAAI = dyn_cast<VAArgInst>(I))
return remove(VAAI);
return true;
// AliasSet/AliasSetTracker Printing Support
//===----------------------------------------------------------------------===//
-void AliasSet::print(std::ostream &OS) const {
- OS << " AliasSet[" << (void*)this << "," << RefCount << "] ";
+void AliasSet::print(raw_ostream &OS) const {
+ OS << " AliasSet[" << format("0x%p", (void*)this) << "," << RefCount << "] ";
OS << (AliasTy == MustAlias ? "must" : "may") << " alias, ";
switch (AccessTy) {
case NoModRef: OS << "No access "; break;
OS << "\n";
}
-void AliasSetTracker::print(std::ostream &OS) const {
+void AliasSetTracker::print(raw_ostream &OS) const {
OS << "Alias Set Tracker: " << AliasSets.size() << " alias sets for "
<< PointerMap.size() << " pointer values.\n";
for (const_iterator I = begin(), E = end(); I != E; ++I)
OS << "\n";
}
-void AliasSet::dump() const { print (cerr); }
-void AliasSetTracker::dump() const { print(cerr); }
+void AliasSet::dump() const { print(dbgs()); }
+void AliasSetTracker::dump() const { print(dbgs()); }
//===----------------------------------------------------------------------===//
// ASTCallbackVH Class Implementation
}
AliasSetTracker::ASTCallbackVH::ASTCallbackVH(Value *V, AliasSetTracker *ast)
- : CallbackVH(V == DenseMapInfo<Value *>::getEmptyKey() ? 0 :
- V == DenseMapInfo<Value *>::getTombstoneKey() ? 0 :
- V),
- AST(ast) {}
+ : CallbackVH(V), AST(ast) {}
+
+AliasSetTracker::ASTCallbackVH &
+AliasSetTracker::ASTCallbackVH::operator=(Value *V) {
+ return *this = ASTCallbackVH(V, AST);
+}
//===----------------------------------------------------------------------===//
// AliasSetPrinter Pass
//===----------------------------------------------------------------------===//
namespace {
- class VISIBILITY_HIDDEN AliasSetPrinter : public FunctionPass {
+ class AliasSetPrinter : public FunctionPass {
AliasSetTracker *Tracker;
public:
static char ID; // Pass identification, replacement for typeid
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
Tracker->add(&*I);
- Tracker->print(cerr);
+ Tracker->print(errs());
delete Tracker;
return false;
}