From 543475658552c2803de6520c303fb834098ed88f Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 31 Jul 2009 03:02:41 +0000 Subject: [PATCH] Revert r77654, it appears to be causing llvm-gcc bootstrap failures, and many failures when building assorted projects with clang. --- Reverse-merging r77654 into '.': U include/llvm/CodeGen/Passes.h U include/llvm/CodeGen/MachineFunctionPass.h U include/llvm/CodeGen/MachineFunction.h U include/llvm/CodeGen/LazyLiveness.h U include/llvm/CodeGen/SelectionDAGISel.h D include/llvm/CodeGen/MachineFunctionAnalysis.h U include/llvm/Function.h U lib/Target/CellSPU/SPUISelDAGToDAG.cpp U lib/Target/PowerPC/PPCISelDAGToDAG.cpp U lib/CodeGen/LLVMTargetMachine.cpp U lib/CodeGen/MachineVerifier.cpp U lib/CodeGen/MachineFunction.cpp U lib/CodeGen/PrologEpilogInserter.cpp U lib/CodeGen/MachineLoopInfo.cpp U lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp D lib/CodeGen/MachineFunctionAnalysis.cpp D lib/CodeGen/MachineFunctionPass.cpp U lib/CodeGen/LiveVariables.cpp llvm-svn: 77661 --- llvm/include/llvm/CodeGen/LazyLiveness.h | 1 - llvm/include/llvm/CodeGen/MachineFunction.h | 21 ++++++- .../include/llvm/CodeGen/MachineFunctionAnalysis.h | 49 --------------- llvm/include/llvm/CodeGen/MachineFunctionPass.h | 16 ++--- llvm/include/llvm/CodeGen/Passes.h | 5 ++ llvm/include/llvm/CodeGen/SelectionDAGISel.h | 5 +- llvm/include/llvm/Function.h | 3 +- llvm/lib/CodeGen/LLVMTargetMachine.cpp | 19 ++++-- llvm/lib/CodeGen/LiveVariables.cpp | 1 - llvm/lib/CodeGen/MachineFunction.cpp | 73 +++++++++++++++++++++- llvm/lib/CodeGen/MachineFunctionAnalysis.cpp | 45 ------------- llvm/lib/CodeGen/MachineFunctionPass.cpp | 50 --------------- llvm/lib/CodeGen/MachineLoopInfo.cpp | 1 - llvm/lib/CodeGen/MachineVerifier.cpp | 1 - llvm/lib/CodeGen/PrologEpilogInserter.cpp | 1 + llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 11 ++-- llvm/lib/Target/CellSPU/SPUISelDAGToDAG.cpp | 4 +- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 17 +++-- 18 files changed, 136 insertions(+), 187 deletions(-) delete mode 100644 llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h delete mode 100644 llvm/lib/CodeGen/MachineFunctionAnalysis.cpp delete mode 100644 llvm/lib/CodeGen/MachineFunctionPass.cpp diff --git a/llvm/include/llvm/CodeGen/LazyLiveness.h b/llvm/include/llvm/CodeGen/LazyLiveness.h index 388b638..82e4a15 100644 --- a/llvm/include/llvm/CodeGen/LazyLiveness.h +++ b/llvm/include/llvm/CodeGen/LazyLiveness.h @@ -34,7 +34,6 @@ public: void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequired(); - MachineFunctionPass::getAnalysisUsage(AU); } bool runOnMachineFunction(MachineFunction &mf); diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index b306583a..ea6a384 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -67,7 +67,7 @@ struct MachineFunctionInfo { }; class MachineFunction : private Annotation { - Function *Fn; + const Function *Fn; const TargetMachine &Target; // RegInfo - Information about each register in use in the function. @@ -115,12 +115,12 @@ class MachineFunction : private Annotation { unsigned Alignment; public: - MachineFunction(Function *Fn, const TargetMachine &TM); + MachineFunction(const Function *Fn, const TargetMachine &TM); ~MachineFunction(); /// getFunction - Return the LLVM function that this machine code represents /// - Function *getFunction() const { return Fn; } + const Function *getFunction() const { return Fn; } /// getTarget - Return the target machine this machine code is compiled with /// @@ -229,6 +229,21 @@ public: /// void dump() const; + /// construct - Allocate and initialize a MachineFunction for a given Function + /// and Target + /// + static MachineFunction& construct(const Function *F, const TargetMachine &TM); + + /// destruct - Destroy the MachineFunction corresponding to a given Function + /// + static void destruct(const Function *F); + + /// get - Return a handle to a MachineFunction corresponding to the given + /// Function. This should not be called before "construct()" for a given + /// Function. + /// + static MachineFunction& get(const Function *F); + // Provide accessors for the MachineBasicBlock list... typedef BasicBlockListType::iterator iterator; typedef BasicBlockListType::const_iterator const_iterator; diff --git a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h deleted file mode 100644 index 5f1ff56..0000000 --- a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h +++ /dev/null @@ -1,49 +0,0 @@ -//===-- MachineFunctionAnalysis.h - Owner of MachineFunctions ----*-C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the MachineFunctionAnalysis class. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CODEGEN_MACHINE_FUNCTION_ANALYSIS_H -#define LLVM_CODEGEN_MACHINE_FUNCTION_ANALYSIS_H - -#include "llvm/Pass.h" -#include "llvm/Target/TargetMachine.h" - -namespace llvm { - -class MachineFunction; - -/// MachineFunctionAnalysis - This class is a Pass that manages a -/// MachineFunction object. -struct MachineFunctionAnalysis : public FunctionPass { -private: - const TargetMachine &TM; - CodeGenOpt::Level OptLevel; - MachineFunction *MF; - -public: - static char ID; - explicit MachineFunctionAnalysis(TargetMachine &tm, - CodeGenOpt::Level OL = CodeGenOpt::Default); - - - MachineFunction &getMF() const { return *MF; } - CodeGenOpt::Level getOptLevel() const { return OptLevel; } - -private: - virtual bool runOnFunction(Function &F); - virtual void releaseMemory(); - virtual void getAnalysisUsage(AnalysisUsage &AU) const; -}; - -} // End llvm namespace - -#endif diff --git a/llvm/include/llvm/CodeGen/MachineFunctionPass.h b/llvm/include/llvm/CodeGen/MachineFunctionPass.h index 6f7c216..6b5e64a 100644 --- a/llvm/include/llvm/CodeGen/MachineFunctionPass.h +++ b/llvm/include/llvm/CodeGen/MachineFunctionPass.h @@ -24,25 +24,19 @@ namespace llvm { -/// MachineFunctionPass - This class adapts the FunctionPass interface to -/// allow convenient creation of passes that operate on the MachineFunction -/// representation. Instead of overriding runOnFunction, subclasses -/// override runOnMachineFunction. -class MachineFunctionPass : public FunctionPass { -protected: + // FIXME: This pass should declare that the pass does not invalidate any LLVM + // passes. +struct MachineFunctionPass : public FunctionPass { explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {} explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {} +protected: /// runOnMachineFunction - This method must be overloaded to perform the /// desired machine code transformation or analysis. /// virtual bool runOnMachineFunction(MachineFunction &MF) = 0; - /// getAnalysisUsage - Subclasses that override getAnalysisUsage - /// must call this. - virtual void getAnalysisUsage(AnalysisUsage &AU) const; - -private: +public: bool runOnFunction(Function &F); }; diff --git a/llvm/include/llvm/CodeGen/Passes.h b/llvm/include/llvm/CodeGen/Passes.h index fa570b5..e0ac416 100644 --- a/llvm/include/llvm/CodeGen/Passes.h +++ b/llvm/include/llvm/CodeGen/Passes.h @@ -146,6 +146,11 @@ namespace llvm { /// by seeing if the labels map to the same reduced label. FunctionPass *createDebugLabelFoldingPass(); + /// MachineCodeDeletion Pass - This pass deletes all of the machine code for + /// the current function, which should happen after the function has been + /// emitted to a .s file or to memory. + FunctionPass *createMachineCodeDeleter(); + /// getRegisterAllocator - This creates an instance of the register allocator /// for the Sparc. FunctionPass *getRegisterAllocator(TargetMachine &T); diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h index 51f90ac..d2c0dc4 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h @@ -19,7 +19,6 @@ #include "llvm/Pass.h" #include "llvm/Constant.h" #include "llvm/CodeGen/SelectionDAG.h" -#include "llvm/CodeGen/MachineFunctionPass.h" namespace llvm { class FastISel; @@ -40,7 +39,7 @@ namespace llvm { /// SelectionDAGISel - This is the common base class used for SelectionDAG-based /// pattern-matching instruction selectors. -class SelectionDAGISel : public MachineFunctionPass { +class SelectionDAGISel : public FunctionPass { public: const TargetMachine &TM; TargetLowering &TLI; @@ -63,7 +62,7 @@ public: virtual void getAnalysisUsage(AnalysisUsage &AU) const; - virtual bool runOnMachineFunction(MachineFunction &MF); + virtual bool runOnFunction(Function &Fn); unsigned MakeReg(MVT VT); diff --git a/llvm/include/llvm/Function.h b/llvm/include/llvm/Function.h index 90d9b0e..57ebfb1 100644 --- a/llvm/include/llvm/Function.h +++ b/llvm/include/llvm/Function.h @@ -21,6 +21,7 @@ #include "llvm/GlobalValue.h" #include "llvm/BasicBlock.h" #include "llvm/Argument.h" +#include "llvm/Support/Annotation.h" #include "llvm/Attributes.h" namespace llvm { @@ -65,7 +66,7 @@ private: mutable ilist_node Sentinel; }; -class Function : public GlobalValue, +class Function : public GlobalValue, public Annotable, public ilist_node { public: typedef iplist ArgumentListType; diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp index 6f0581a..0f33ee3 100644 --- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp +++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp @@ -18,7 +18,6 @@ #include "llvm/Analysis/LoopPass.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/GCStrategy.h" -#include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetRegistry.h" @@ -119,6 +118,9 @@ bool LLVMTargetMachine::addPassesToEmitFileFinish(PassManagerBase &PM, PM.add(createGCInfoDeleter()); + // Delete machine code for this function + PM.add(createMachineCodeDeleter()); + return false; // success! } @@ -135,6 +137,9 @@ bool LLVMTargetMachine::addPassesToEmitFileFinish(PassManagerBase &PM, PM.add(createGCInfoDeleter()); + // Delete machine code for this function + PM.add(createMachineCodeDeleter()); + return false; // success! } @@ -151,6 +156,9 @@ bool LLVMTargetMachine::addPassesToEmitFileFinish(PassManagerBase &PM, PM.add(createGCInfoDeleter()); + // Delete machine code for this function + PM.add(createMachineCodeDeleter()); + return false; // success! } @@ -176,6 +184,9 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(PassManagerBase &PM, PM.add(createGCInfoDeleter()); + // Delete machine code for this function + PM.add(createMachineCodeDeleter()); + return false; // success! } @@ -201,6 +212,9 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(PassManagerBase &PM, PM.add(createGCInfoDeleter()); + // Delete machine code for this function + PM.add(createMachineCodeDeleter()); + return false; // success! } @@ -251,9 +265,6 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM, // Standard Lower-Level Passes. - // Set up a MachineFunction for the rest of CodeGen to work on. - PM.add(new MachineFunctionAnalysis(*this, OptLevel)); - // Enable FastISel with -fast, but allow that to be overridden. if (EnableFastISelOption == cl::BOU_TRUE || (OptLevel == CodeGenOpt::None && EnableFastISelOption != cl::BOU_FALSE)) diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp index 2034566..bb72d80 100644 --- a/llvm/lib/CodeGen/LiveVariables.cpp +++ b/llvm/lib/CodeGen/LiveVariables.cpp @@ -48,7 +48,6 @@ static RegisterPass X("livevars", "Live Variable Analysis"); void LiveVariables::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequiredID(UnreachableMachineBlockElimID); AU.setPreservesAll(); - MachineFunctionPass::getAnalysisUsage(AU); } void LiveVariables::VarInfo::dump() const { diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index aa3cfe2..98396ee 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -36,6 +36,15 @@ #include using namespace llvm; +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; + + return runOnMachineFunction(MachineFunction::get(&F)); +} + namespace { struct VISIBILITY_HIDDEN Printer : public MachineFunctionPass { static char ID; @@ -50,7 +59,6 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); - MachineFunctionPass::getAnalysisUsage(AU); } bool runOnMachineFunction(MachineFunction &MF) { @@ -70,6 +78,31 @@ FunctionPass *llvm::createMachineFunctionPrinterPass(std::ostream *OS, return new Printer(OS, Banner); } +namespace { + struct VISIBILITY_HIDDEN Deleter : public MachineFunctionPass { + static char ID; + Deleter() : MachineFunctionPass(&ID) {} + + const char *getPassName() const { return "Machine Code Deleter"; } + + bool runOnMachineFunction(MachineFunction &MF) { + // Delete the annotation from the function now. + MachineFunction::destruct(MF.getFunction()); + return true; + } + }; + char Deleter::ID = 0; +} + +/// MachineCodeDeletion Pass - This pass deletes all of the machine code for +/// the current function, which should happen after the function has been +/// emitted to a .s file or to memory. +FunctionPass *llvm::createMachineCodeDeleter() { + return new Deleter(); +} + + + //===---------------------------------------------------------------------===// // MachineFunction implementation //===---------------------------------------------------------------------===// @@ -78,7 +111,7 @@ void ilist_traits::deleteNode(MachineBasicBlock *MBB) { MBB->getParent()->DeleteMachineBasicBlock(MBB); } -MachineFunction::MachineFunction(Function *F, +MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM) : Annotation(AnnotationManager::getID("CodeGen::MachineCodeForFunction")), Fn(F), Target(TM) { @@ -323,6 +356,42 @@ void MachineFunction::viewCFGOnly() const #endif // NDEBUG } +// The next two methods are used to construct and to retrieve +// the MachineCodeForFunction object for the given function. +// construct() -- Allocates and initializes for a given function and target +// get() -- Returns a handle to the object. +// This should not be called before "construct()" +// for a given Function. +// +MachineFunction& +MachineFunction::construct(const Function *Fn, const TargetMachine &Tar) +{ + AnnotationID MF_AID = + AnnotationManager::getID("CodeGen::MachineCodeForFunction"); + assert(Fn->getAnnotation(MF_AID) == 0 && + "Object already exists for this function!"); + MachineFunction* mcInfo = new MachineFunction(Fn, Tar); + Fn->addAnnotation(mcInfo); + return *mcInfo; +} + +void MachineFunction::destruct(const Function *Fn) { + AnnotationID MF_AID = + AnnotationManager::getID("CodeGen::MachineCodeForFunction"); + bool Deleted = Fn->deleteAnnotation(MF_AID); + assert(Deleted && "Machine code did not exist for function!"); + Deleted = Deleted; // silence warning when no assertions. +} + +MachineFunction& MachineFunction::get(const Function *F) +{ + AnnotationID MF_AID = + AnnotationManager::getID("CodeGen::MachineCodeForFunction"); + MachineFunction *mc = (MachineFunction*)F->getAnnotation(MF_AID); + assert(mc && "Call construct() method first to allocate the object"); + return *mc; +} + /// addLiveIn - Add the specified physical register as a live-in value and /// create a corresponding virtual register for it. unsigned MachineFunction::addLiveIn(unsigned PReg, diff --git a/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp b/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp deleted file mode 100644 index 8b7dba8..0000000 --- a/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp +++ /dev/null @@ -1,45 +0,0 @@ -//===-- MachineFunctionAnalysis.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 MachineFunctionAnalysis members. -// -//===----------------------------------------------------------------------===// - -#include "llvm/CodeGen/MachineFunctionAnalysis.h" -#include "llvm/CodeGen/MachineFunction.h" -using namespace llvm; - -// Register this pass with PassInfo directly to avoid having to define -// a default constructor. -static PassInfo -X("Machine Function Analysis", "machine-function-analysis", - intptr_t(&MachineFunctionAnalysis::ID), 0, - /*CFGOnly=*/false, /*is_analysis=*/true); - -char MachineFunctionAnalysis::ID = 0; - -MachineFunctionAnalysis::MachineFunctionAnalysis(TargetMachine &tm, - CodeGenOpt::Level OL) : - FunctionPass(&ID), TM(tm), OptLevel(OL), MF(0) { -} - -bool MachineFunctionAnalysis::runOnFunction(Function &F) { - assert(!MF && "MachineFunctionAnalysis already initialized!"); - MF = new MachineFunction(&F, TM); - return false; -} - -void MachineFunctionAnalysis::releaseMemory() { - delete MF; - MF = 0; -} - -void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); -} diff --git a/llvm/lib/CodeGen/MachineFunctionPass.cpp b/llvm/lib/CodeGen/MachineFunctionPass.cpp deleted file mode 100644 index d8a7c55..0000000 --- a/llvm/lib/CodeGen/MachineFunctionPass.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===-- 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/Analysis/AliasAnalysis.h" -#include "llvm/Analysis/ScalarEvolution.h" -#include "llvm/Analysis/IVUsers.h" -#include "llvm/Analysis/LiveValues.h" -#include "llvm/Analysis/LoopDependenceAnalysis.h" -#include "llvm/Analysis/MemoryDependenceAnalysis.h" -#include "llvm/CodeGen/MachineFunctionAnalysis.h" -#include "llvm/CodeGen/MachineFunctionPass.h" -using namespace llvm; - -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().getMF(); - return runOnMachineFunction(MF); -} - -void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); - - // MachineFunctionPass preserves all LLVM IR passes, but there's no - // high-level way to express this. Instead, just list a bunch of - // passes explicitly. - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.addPreserved(); - AU.setPreservesCFG(); - - FunctionPass::getAnalysisUsage(AU); -} diff --git a/llvm/lib/CodeGen/MachineLoopInfo.cpp b/llvm/lib/CodeGen/MachineLoopInfo.cpp index 2da8e37..a5694ae 100644 --- a/llvm/lib/CodeGen/MachineLoopInfo.cpp +++ b/llvm/lib/CodeGen/MachineLoopInfo.cpp @@ -41,5 +41,4 @@ bool MachineLoopInfo::runOnMachineFunction(MachineFunction &) { void MachineLoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequired(); - MachineFunctionPass::getAnalysisUsage(AU); } diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index a13d39e..d9c37de 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -55,7 +55,6 @@ namespace { void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); - MachineFunctionPass::getAnalysisUsage(AU); } bool runOnMachineFunction(MachineFunction &MF); diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp index 9d5c55b..5aa37c9 100644 --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp @@ -111,6 +111,7 @@ bool PEI::runOnMachineFunction(MachineFunction &Fn) { #if 0 void PEI::getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesCFG(); if (ShrinkWrapping || ShrinkWrapFunc != "") { AU.addRequired(); AU.addRequired(); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 1072c95..ab87449 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -29,7 +29,6 @@ #include "llvm/CodeGen/GCStrategy.h" #include "llvm/CodeGen/GCMetadata.h" #include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" @@ -268,7 +267,7 @@ static void EmitLiveInCopies(MachineBasicBlock *EntryMBB, //===----------------------------------------------------------------------===// SelectionDAGISel::SelectionDAGISel(TargetMachine &tm, CodeGenOpt::Level OL) : - MachineFunctionPass(&ID), TM(tm), TLI(*tm.getTargetLowering()), + FunctionPass(&ID), TM(tm), TLI(*tm.getTargetLowering()), FuncInfo(new FunctionLoweringInfo(TLI)), CurDAG(new SelectionDAG(TLI, *FuncInfo)), SDL(new SelectionDAGLowering(*CurDAG, TLI, *FuncInfo, OL)), @@ -292,12 +291,9 @@ void SelectionDAGISel::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.addRequired(); AU.setPreservesAll(); - MachineFunctionPass::getAnalysisUsage(AU); } -bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { - Function &Fn = *mf.getFunction(); - +bool SelectionDAGISel::runOnFunction(Function &Fn) { // Do some sanity-checking on the command-line options. assert((!EnableFastISelVerbose || EnableFastISel) && "-fast-isel-verbose requires -fast-isel"); @@ -309,11 +305,12 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { if (Fn.hasAvailableExternallyLinkage()) return false; + // Get alias analysis for load/store combining. AA = &getAnalysis(); TargetMachine &TM = TLI.getTargetMachine(); - MF = &mf; + MF = &MachineFunction::construct(&Fn, TM); const TargetInstrInfo &TII = *TM.getInstrInfo(); const TargetRegisterInfo &TRI = *TM.getRegisterInfo(); diff --git a/llvm/lib/Target/CellSPU/SPUISelDAGToDAG.cpp b/llvm/lib/Target/CellSPU/SPUISelDAGToDAG.cpp index cca5288..d29ddaa 100644 --- a/llvm/lib/Target/CellSPU/SPUISelDAGToDAG.cpp +++ b/llvm/lib/Target/CellSPU/SPUISelDAGToDAG.cpp @@ -253,10 +253,10 @@ namespace { SPUtli(*tm.getTargetLowering()) { } - virtual bool runOnMachineFunction(MachineFunction &MF) { + virtual bool runOnFunction(Function &Fn) { // Make sure we re-emit a set of the global base reg if necessary GlobalBaseReg = 0; - SelectionDAGISel::runOnMachineFunction(MF); + SelectionDAGISel::runOnFunction(Fn); return true; } diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index d77ce57..9221355 100644 --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -20,7 +20,6 @@ #include "PPCHazardRecognizers.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/CodeGen/SelectionDAGISel.h" @@ -52,12 +51,17 @@ namespace { PPCLowering(*TM.getTargetLowering()), PPCSubTarget(*TM.getSubtargetImpl()) {} - virtual bool runOnMachineFunction(MachineFunction &MF) { + virtual bool runOnFunction(Function &Fn) { + // Do not codegen any 'available_externally' functions at all, they have + // definitions outside the translation unit. + if (Fn.hasAvailableExternallyLinkage()) + return false; + // Make sure we re-emit a set of the global base reg if necessary GlobalBaseReg = 0; - SelectionDAGISel::runOnMachineFunction(MF); + SelectionDAGISel::runOnFunction(Fn); - InsertVRSaveCode(MF); + InsertVRSaveCode(Fn); return true; } @@ -177,7 +181,7 @@ namespace { /// SelectionDAGISel when it has created a SelectionDAG for us to codegen. virtual void InstructionSelect(); - void InsertVRSaveCode(MachineFunction &MF); + void InsertVRSaveCode(Function &Fn); virtual const char *getPassName() const { return "PowerPC DAG->DAG Pattern Instruction Selection"; @@ -214,12 +218,13 @@ void PPCDAGToDAGISel::InstructionSelect() { /// InsertVRSaveCode - Once the entire function has been instruction selected, /// all virtual registers are created and all machine instructions are built, /// check to see if we need to save/restore VRSAVE. If so, do it. -void PPCDAGToDAGISel::InsertVRSaveCode(MachineFunction &Fn) { +void PPCDAGToDAGISel::InsertVRSaveCode(Function &F) { // Check to see if this function uses vector registers, which means we have to // save and restore the VRSAVE register and update it with the regs we use. // // In this case, there will be virtual registers of vector type type created // by the scheduler. Detect them now. + MachineFunction &Fn = MachineFunction::get(&F); bool HasVectorVReg = false; for (unsigned i = TargetRegisterInfo::FirstVirtualRegister, e = RegInfo->getLastVirtReg()+1; i != e; ++i) -- 2.7.4