mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-29 10:32:47 +00:00
52334f2ad8
abomination. For starters, this API is incredibly slow. In order to lookup the name of a pass it must take a memory fence to acquire a pointer to the managed static pass registry, and then potentially acquire locks while it consults this registry for information about what passes exist by that name. This stops the world of LLVMs in your process no matter how little they cared about the result. To make this more joyful, you'll note that we are preserving many passes which *do not exist* any more, or are not even analyses which one might wish to have be preserved. This means we do all the work only to say "nope" with no error to the user. String-based APIs are a *bad idea*. String-based APIs that cannot produce any meaningful error are an even worse idea. =/ I have a patch that simply removes this API completely, but I'm hesitant to commit it as I don't really want to perniciously break out-of-tree users of the old pass manager. I'd rather they just have to migrate to the new one at some point. If others disagree and would like me to kill it with fire, just say the word. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227294 91177308-0d34-0410-b5e6-96231b3b80d8
64 lines
2.4 KiB
C++
64 lines
2.4 KiB
C++
//===-- MachineFunctionPass.cpp -------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains the definitions of the MachineFunctionPass members.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
|
#include "llvm/Analysis/DominanceFrontier.h"
|
|
#include "llvm/Analysis/IVUsers.h"
|
|
#include "llvm/Analysis/LoopInfo.h"
|
|
#include "llvm/Analysis/LoopInfo.h"
|
|
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
|
|
#include "llvm/Analysis/ScalarEvolution.h"
|
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
|
#include "llvm/CodeGen/Passes.h"
|
|
#include "llvm/CodeGen/StackProtector.h"
|
|
#include "llvm/IR/Dominators.h"
|
|
#include "llvm/IR/Function.h"
|
|
using namespace llvm;
|
|
|
|
Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O,
|
|
const std::string &Banner) const {
|
|
return createMachineFunctionPrinterPass(O, Banner);
|
|
}
|
|
|
|
bool MachineFunctionPass::runOnFunction(Function &F) {
|
|
// Do not codegen any 'available_externally' functions at all, they have
|
|
// definitions outside the translation unit.
|
|
if (F.hasAvailableExternallyLinkage())
|
|
return false;
|
|
|
|
MachineFunction &MF = getAnalysis<MachineFunctionAnalysis>().getMF();
|
|
return runOnMachineFunction(MF);
|
|
}
|
|
|
|
void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
AU.addRequired<MachineFunctionAnalysis>();
|
|
AU.addPreserved<MachineFunctionAnalysis>();
|
|
|
|
// MachineFunctionPass preserves all LLVM IR passes, but there's no
|
|
// high-level way to express this. Instead, just list a bunch of
|
|
// passes explicitly. This does not include setPreservesCFG,
|
|
// because CodeGen overloads that to mean preserving the MachineBasicBlock
|
|
// CFG in addition to the LLVM IR CFG.
|
|
AU.addPreserved<AliasAnalysis>();
|
|
AU.addPreserved<DominanceFrontier>();
|
|
AU.addPreserved<DominatorTreeWrapperPass>();
|
|
AU.addPreserved<IVUsers>();
|
|
AU.addPreserved<LoopInfoWrapperPass>();
|
|
AU.addPreserved<MemoryDependenceAnalysis>();
|
|
AU.addPreserved<ScalarEvolution>();
|
|
AU.addPreserved<StackProtector>();
|
|
|
|
FunctionPass::getAnalysisUsage(AU);
|
|
}
|