1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/lib/Analysis/NoAliasAnalysis.cpp
Mehdi Amini 29ebc2d39f Make DataLayout Non-Optional in the Module
Summary:
DataLayout keeps the string used for its creation.

As a side effect it is no longer needed in the Module.
This is "almost" NFC, the string is no longer
canonicalized, you can't rely on two "equals" DataLayout
having the same string returned by getStringRepresentation().

Get rid of DataLayoutPass: the DataLayout is in the Module

The DataLayout is "per-module", let's enforce this by not
duplicating it more than necessary.
One more step toward non-optionality of the DataLayout in the
module.

Make DataLayout Non-Optional in the Module

Module->getDataLayout() will never returns nullptr anymore.

Reviewers: echristo

Subscribers: resistor, llvm-commits, jholewinski

Differential Revision: http://reviews.llvm.org/D7992

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 231270
2015-03-04 18:43:29 +00:00

98 lines
3.4 KiB
C++

//===- NoAliasAnalysis.cpp - Minimal Alias Analysis Impl ------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the default implementation of the Alias Analysis interface
// that simply returns "I don't know" for all queries.
//
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
using namespace llvm;
namespace {
/// NoAA - This class implements the -no-aa pass, which always returns "I
/// don't know" for alias queries. NoAA is unlike other alias analysis
/// implementations, in that it does not chain to a previous analysis. As
/// such it doesn't follow many of the rules that other alias analyses must.
///
struct NoAA : public ImmutablePass, public AliasAnalysis {
static char ID; // Class identification, replacement for typeinfo
NoAA() : ImmutablePass(ID) {
initializeNoAAPass(*PassRegistry::getPassRegistry());
}
void getAnalysisUsage(AnalysisUsage &AU) const override {}
bool doInitialization(Module &M) override {
// Note: NoAA does not call InitializeAliasAnalysis because it's
// special and does not support chaining.
DL = &M.getDataLayout();
return true;
}
AliasResult alias(const Location &LocA, const Location &LocB) override {
return MayAlias;
}
ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override {
return UnknownModRefBehavior;
}
ModRefBehavior getModRefBehavior(const Function *F) override {
return UnknownModRefBehavior;
}
bool pointsToConstantMemory(const Location &Loc, bool OrLocal) override {
return false;
}
Location getArgLocation(ImmutableCallSite CS, unsigned ArgIdx,
ModRefResult &Mask) override {
Mask = ModRef;
AAMDNodes AATags;
CS->getAAMetadata(AATags);
return Location(CS.getArgument(ArgIdx), UnknownSize, AATags);
}
ModRefResult getModRefInfo(ImmutableCallSite CS,
const Location &Loc) override {
return ModRef;
}
ModRefResult getModRefInfo(ImmutableCallSite CS1,
ImmutableCallSite CS2) override {
return ModRef;
}
void deleteValue(Value *V) override {}
void copyValue(Value *From, Value *To) override {}
void addEscapingUse(Use &U) override {}
/// getAdjustedAnalysisPointer - This method is used when a pass implements
/// an analysis interface through multiple inheritance. If needed, it
/// should override this to adjust the this pointer as needed for the
/// specified pass info.
void *getAdjustedAnalysisPointer(const void *ID) override {
if (ID == &AliasAnalysis::ID)
return (AliasAnalysis*)this;
return this;
}
};
} // End of anonymous namespace
// Register this pass...
char NoAA::ID = 0;
INITIALIZE_AG_PASS(NoAA, AliasAnalysis, "no-aa",
"No Alias Analysis (always returns 'may' alias)",
true, true, true)
ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }