mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-05 12:31:33 +00:00
c1a9c38190
directly model in the new PM. This also was an incredibly brittle and expensive update API that was never fully utilized by all the passes that claimed to preserve AA, nor could it reasonably have been extended to all of them. Any number of places add uses of values. If we ever wanted to reliably instrument this, we would want a callback hook much like we have with ValueHandles, but doing this for every use addition seems *extremely* expensive in terms of compile time. The only user of this update mechanism is GlobalsModRef. The idea of using this to keep it up to date doesn't really work anyways as its analysis requires a symmetric analysis of two different memory locations. It would be very hard to make updates be sufficiently rigorous to *guarantee* symmetric analysis in this way, and it pretty certainly isn't true today. However, folks have been using GMR with this update for a long time and seem to not be hitting the issues. The reported issue that the update hook fixes isn't even a problem any more as other changes to GetUnderlyingObject worked around it, and that issue stemmed from *many* years ago. As a consequence, a prior patch provided a flag to control the unsafe behavior of GMR, and this patch removes the update mechanism that has questionable compile-time tradeoffs and is causing problems with moving to the new pass manager. Note the lack of test updates -- not one test in tree actually requires this update, even for a contrived case. All of this was extensively discussed on the dev list, this patch will just enact what that discussion decides on. I'm sending it for review in part to show what I'm planning, and in part to show the *amazing* amount of work this avoids. Every call to the AA here is something like three to six indirect function calls, which in the non-LTO pipeline never do any work! =[ Differential Revision: http://reviews.llvm.org/D11214 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242605 91177308-0d34-0410-b5e6-96231b3b80d8
95 lines
3.3 KiB
C++
95 lines
3.3 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 MemoryLocation &LocA,
|
|
const MemoryLocation &LocB) override {
|
|
return MayAlias;
|
|
}
|
|
|
|
ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override {
|
|
return UnknownModRefBehavior;
|
|
}
|
|
ModRefBehavior getModRefBehavior(const Function *F) override {
|
|
return UnknownModRefBehavior;
|
|
}
|
|
|
|
bool pointsToConstantMemory(const MemoryLocation &Loc,
|
|
bool OrLocal) override {
|
|
return false;
|
|
}
|
|
ModRefResult getArgModRefInfo(ImmutableCallSite CS,
|
|
unsigned ArgIdx) override {
|
|
return ModRef;
|
|
}
|
|
|
|
ModRefResult getModRefInfo(ImmutableCallSite CS,
|
|
const MemoryLocation &Loc) override {
|
|
return ModRef;
|
|
}
|
|
ModRefResult getModRefInfo(ImmutableCallSite CS1,
|
|
ImmutableCallSite CS2) override {
|
|
return ModRef;
|
|
}
|
|
|
|
void deleteValue(Value *V) 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(); }
|