mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
Revert r279564. It introduces undefined behavior (binding a reference to a
dereferenced null pointer) in MachineModuleInfo::MachineModuleInfo that causes -Werror builds (including several buildbots) to fail. llvm-svn: 279580
This commit is contained in:
parent
9fc2f3ceff
commit
d13903d090
55
include/llvm/CodeGen/MachineFunctionAnalysis.h
Normal file
55
include/llvm/CodeGen/MachineFunctionAnalysis.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
//===-- 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_MACHINEFUNCTIONANALYSIS_H
|
||||||
|
#define LLVM_CODEGEN_MACHINEFUNCTIONANALYSIS_H
|
||||||
|
|
||||||
|
#include "llvm/Pass.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
|
class MachineFunction;
|
||||||
|
class MachineFunctionInitializer;
|
||||||
|
class TargetMachine;
|
||||||
|
|
||||||
|
/// MachineFunctionAnalysis - This class is a Pass that manages a
|
||||||
|
/// MachineFunction object.
|
||||||
|
struct MachineFunctionAnalysis : public FunctionPass {
|
||||||
|
private:
|
||||||
|
const TargetMachine &TM;
|
||||||
|
MachineFunction *MF;
|
||||||
|
unsigned NextFnNum;
|
||||||
|
MachineFunctionInitializer *MFInitializer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static char ID;
|
||||||
|
explicit MachineFunctionAnalysis(const TargetMachine &tm,
|
||||||
|
MachineFunctionInitializer *MFInitializer);
|
||||||
|
~MachineFunctionAnalysis() override;
|
||||||
|
|
||||||
|
MachineFunction &getMF() const { return *MF; }
|
||||||
|
|
||||||
|
const char* getPassName() const override {
|
||||||
|
return "Machine Function Analysis";
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool doInitialization(Module &M) override;
|
||||||
|
bool runOnFunction(Function &F) override;
|
||||||
|
void releaseMemory() override;
|
||||||
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // End llvm namespace
|
||||||
|
|
||||||
|
#endif
|
@ -54,7 +54,6 @@ class BlockAddress;
|
|||||||
class MDNode;
|
class MDNode;
|
||||||
class MMIAddrLabelMap;
|
class MMIAddrLabelMap;
|
||||||
class MachineBasicBlock;
|
class MachineBasicBlock;
|
||||||
class MachineFunctionInitializer;
|
|
||||||
class MachineFunction;
|
class MachineFunction;
|
||||||
class Module;
|
class Module;
|
||||||
class PointerType;
|
class PointerType;
|
||||||
@ -108,8 +107,6 @@ protected:
|
|||||||
/// schemes and reformated for specific use.
|
/// schemes and reformated for specific use.
|
||||||
///
|
///
|
||||||
class MachineModuleInfo : public ImmutablePass {
|
class MachineModuleInfo : public ImmutablePass {
|
||||||
const TargetMachine &TM;
|
|
||||||
|
|
||||||
/// Context - This is the MCContext used for the entire code generator.
|
/// Context - This is the MCContext used for the entire code generator.
|
||||||
MCContext Context;
|
MCContext Context;
|
||||||
|
|
||||||
@ -187,14 +184,6 @@ class MachineModuleInfo : public ImmutablePass {
|
|||||||
|
|
||||||
EHPersonality PersonalityTypeCache;
|
EHPersonality PersonalityTypeCache;
|
||||||
|
|
||||||
MachineFunctionInitializer *MFInitializer;
|
|
||||||
/// Maps IR Functions to their corresponding MachineFunctions.
|
|
||||||
DenseMap<const Function*, std::unique_ptr<MachineFunction>> MachineFunctions;
|
|
||||||
/// Next unique number available for a MachineFunction.
|
|
||||||
unsigned NextFnNum = 0;
|
|
||||||
const Function *LastRequest = nullptr; ///< Used for shortcut/cache.
|
|
||||||
MachineFunction *LastResult = nullptr; ///< Used for shortcut/cache.
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
|
|
||||||
@ -213,9 +202,8 @@ public:
|
|||||||
|
|
||||||
MachineModuleInfo(); // DUMMY CONSTRUCTOR, DO NOT CALL.
|
MachineModuleInfo(); // DUMMY CONSTRUCTOR, DO NOT CALL.
|
||||||
// Real constructor.
|
// Real constructor.
|
||||||
MachineModuleInfo(const TargetMachine &TM, const MCAsmInfo &MAI,
|
MachineModuleInfo(const MCAsmInfo &MAI, const MCRegisterInfo &MRI,
|
||||||
const MCRegisterInfo &MRI, const MCObjectFileInfo *MOFI,
|
const MCObjectFileInfo *MOFI);
|
||||||
MachineFunctionInitializer *MFInitializer = nullptr);
|
|
||||||
~MachineModuleInfo() override;
|
~MachineModuleInfo() override;
|
||||||
|
|
||||||
// Initialization and Finalization
|
// Initialization and Finalization
|
||||||
@ -232,15 +220,6 @@ public:
|
|||||||
void setModule(const Module *M) { TheModule = M; }
|
void setModule(const Module *M) { TheModule = M; }
|
||||||
const Module *getModule() const { return TheModule; }
|
const Module *getModule() const { return TheModule; }
|
||||||
|
|
||||||
/// Returns the MachineFunction constructed for the IR function \p F.
|
|
||||||
/// Creates a new MachineFunction and runs the MachineFunctionInitializer
|
|
||||||
/// if none exists yet.
|
|
||||||
MachineFunction &getMachineFunction(const Function &F);
|
|
||||||
|
|
||||||
/// \brief Delete the MachineFunction \p MF and reset the link in the IR
|
|
||||||
/// Function to Machine Function map.
|
|
||||||
void deleteMachineFunctionFor(Function &F);
|
|
||||||
|
|
||||||
/// getInfo - Keep track of various per-function pieces of information for
|
/// getInfo - Keep track of various per-function pieces of information for
|
||||||
/// backends that would like to do so.
|
/// backends that would like to do so.
|
||||||
///
|
///
|
||||||
|
@ -377,9 +377,6 @@ namespace llvm {
|
|||||||
|
|
||||||
/// This pass performs software pipelining on machine instructions.
|
/// This pass performs software pipelining on machine instructions.
|
||||||
extern char &MachinePipelinerID;
|
extern char &MachinePipelinerID;
|
||||||
|
|
||||||
/// This pass frees the memory occupied by the MachineFunction.
|
|
||||||
FunctionPass *createFreeMachineFunctionPass();
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
/// Target machine pass initializer for passes with dependencies. Use with
|
/// Target machine pass initializer for passes with dependencies. Use with
|
||||||
|
@ -314,8 +314,11 @@ public:
|
|||||||
bool DisableVerify = true) override;
|
bool DisableVerify = true) override;
|
||||||
|
|
||||||
/// Add MachineModuleInfo pass to pass manager.
|
/// Add MachineModuleInfo pass to pass manager.
|
||||||
MachineModuleInfo &addMachineModuleInfo(PassManagerBase &PM,
|
MachineModuleInfo &addMachineModuleInfo(PassManagerBase &PM) const;
|
||||||
MachineFunctionInitializer *MFI = nullptr) const;
|
|
||||||
|
/// Add MachineFunctionAnalysis pass to pass manager.
|
||||||
|
void addMachineFunctionAnalysis(PassManagerBase &PM,
|
||||||
|
MachineFunctionInitializer *MFInitializer) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
@ -2571,6 +2571,8 @@ isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy &S) {
|
GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy &S) {
|
||||||
if (!S.usesMetadata())
|
if (!S.usesMetadata())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -59,6 +59,7 @@ add_llvm_library(LLVMCodeGen
|
|||||||
MachineCSE.cpp
|
MachineCSE.cpp
|
||||||
MachineDominanceFrontier.cpp
|
MachineDominanceFrontier.cpp
|
||||||
MachineDominators.cpp
|
MachineDominators.cpp
|
||||||
|
MachineFunctionAnalysis.cpp
|
||||||
MachineFunction.cpp
|
MachineFunction.cpp
|
||||||
MachineFunctionPass.cpp
|
MachineFunctionPass.cpp
|
||||||
MachineFunctionPrinterPass.cpp
|
MachineFunctionPrinterPass.cpp
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "llvm/Analysis/Passes.h"
|
#include "llvm/Analysis/Passes.h"
|
||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/CodeGen/BasicTTIImpl.h"
|
#include "llvm/CodeGen/BasicTTIImpl.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/CodeGen/TargetPassConfig.h"
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
||||||
@ -102,15 +103,19 @@ TargetIRAnalysis LLVMTargetMachine::getTargetIRAnalysis() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MachineModuleInfo &
|
MachineModuleInfo &
|
||||||
LLVMTargetMachine::addMachineModuleInfo(PassManagerBase &PM,
|
LLVMTargetMachine::addMachineModuleInfo(PassManagerBase &PM) const {
|
||||||
MachineFunctionInitializer *MFI) const {
|
MachineModuleInfo *MMI = new MachineModuleInfo(*getMCAsmInfo(),
|
||||||
MachineModuleInfo *MMI = new MachineModuleInfo(*this, *getMCAsmInfo(),
|
|
||||||
*getMCRegisterInfo(),
|
*getMCRegisterInfo(),
|
||||||
getObjFileLowering(), MFI);
|
getObjFileLowering());
|
||||||
PM.add(MMI);
|
PM.add(MMI);
|
||||||
return *MMI;
|
return *MMI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LLVMTargetMachine::addMachineFunctionAnalysis(PassManagerBase &PM,
|
||||||
|
MachineFunctionInitializer *MFInitializer) const {
|
||||||
|
PM.add(new MachineFunctionAnalysis(*this, MFInitializer));
|
||||||
|
}
|
||||||
|
|
||||||
/// addPassesToX helper drives creation and initialization of TargetPassConfig.
|
/// addPassesToX helper drives creation and initialization of TargetPassConfig.
|
||||||
static MCContext *
|
static MCContext *
|
||||||
addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM,
|
addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM,
|
||||||
@ -145,7 +150,8 @@ addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM,
|
|||||||
|
|
||||||
PassConfig->addISelPrepare();
|
PassConfig->addISelPrepare();
|
||||||
|
|
||||||
MachineModuleInfo &MMI = TM->addMachineModuleInfo(PM, MFInitializer);
|
MachineModuleInfo &MMI = TM->addMachineModuleInfo(PM);
|
||||||
|
TM->addMachineFunctionAnalysis(PM, MFInitializer);
|
||||||
|
|
||||||
// Enable FastISel with -fast, but allow that to be overridden.
|
// Enable FastISel with -fast, but allow that to be overridden.
|
||||||
TM->setO0WantsFastISel(EnableFastISelOption != cl::BOU_FALSE);
|
TM->setO0WantsFastISel(EnableFastISelOption != cl::BOU_FALSE);
|
||||||
@ -267,7 +273,6 @@ bool LLVMTargetMachine::addPassesToEmitFile(
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
PM.add(Printer);
|
PM.add(Printer);
|
||||||
PM.add(createFreeMachineFunctionPass());
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -314,7 +319,6 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
PM.add(Printer);
|
PM.add(Printer);
|
||||||
PM.add(createFreeMachineFunctionPass());
|
|
||||||
|
|
||||||
return false; // success!
|
return false; // success!
|
||||||
}
|
}
|
||||||
|
62
lib/CodeGen/MachineFunctionAnalysis.cpp
Normal file
62
lib/CodeGen/MachineFunctionAnalysis.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
//===-- 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/GCMetadata.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionInitializer.h"
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
char MachineFunctionAnalysis::ID = 0;
|
||||||
|
|
||||||
|
MachineFunctionAnalysis::MachineFunctionAnalysis(
|
||||||
|
const TargetMachine &tm, MachineFunctionInitializer *MFInitializer)
|
||||||
|
: FunctionPass(ID), TM(tm), MF(nullptr), MFInitializer(MFInitializer) {
|
||||||
|
initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry());
|
||||||
|
}
|
||||||
|
|
||||||
|
MachineFunctionAnalysis::~MachineFunctionAnalysis() {
|
||||||
|
releaseMemory();
|
||||||
|
assert(!MF && "MachineFunctionAnalysis left initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
|
AU.setPreservesAll();
|
||||||
|
AU.addRequired<MachineModuleInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MachineFunctionAnalysis::doInitialization(Module &M) {
|
||||||
|
MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
|
||||||
|
assert(MMI && "MMI not around yet??");
|
||||||
|
MMI->setModule(&M);
|
||||||
|
NextFnNum = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MachineFunctionAnalysis::runOnFunction(Function &F) {
|
||||||
|
assert(!MF && "MachineFunctionAnalysis already initialized!");
|
||||||
|
MF = new MachineFunction(&F, TM, NextFnNum++,
|
||||||
|
getAnalysis<MachineModuleInfo>());
|
||||||
|
if (MFInitializer) {
|
||||||
|
if (MFInitializer->initializeMachineFunction(*MF))
|
||||||
|
report_fatal_error("Unable to initialize machine function");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MachineFunctionAnalysis::releaseMemory() {
|
||||||
|
delete MF;
|
||||||
|
MF = nullptr;
|
||||||
|
}
|
@ -22,7 +22,7 @@
|
|||||||
#include "llvm/Analysis/ScalarEvolution.h"
|
#include "llvm/Analysis/ScalarEvolution.h"
|
||||||
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
|
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/CodeGen/StackProtector.h"
|
#include "llvm/CodeGen/StackProtector.h"
|
||||||
#include "llvm/IR/Dominators.h"
|
#include "llvm/IR/Dominators.h"
|
||||||
@ -41,9 +41,7 @@ bool MachineFunctionPass::runOnFunction(Function &F) {
|
|||||||
if (F.hasAvailableExternallyLinkage())
|
if (F.hasAvailableExternallyLinkage())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MachineModuleInfo &MMI = getAnalysis<MachineModuleInfo>();
|
MachineFunction &MF = getAnalysis<MachineFunctionAnalysis>().getMF();
|
||||||
MachineFunction &MF = MMI.getMachineFunction(F);
|
|
||||||
|
|
||||||
MachineFunctionProperties &MFProps = MF.getProperties();
|
MachineFunctionProperties &MFProps = MF.getProperties();
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -67,8 +65,8 @@ bool MachineFunctionPass::runOnFunction(Function &F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.addRequired<MachineModuleInfo>();
|
AU.addRequired<MachineFunctionAnalysis>();
|
||||||
AU.addPreserved<MachineModuleInfo>();
|
AU.addPreserved<MachineFunctionAnalysis>();
|
||||||
|
|
||||||
// MachineFunctionPass preserves all LLVM IR passes, but there's no
|
// MachineFunctionPass preserves all LLVM IR passes, but there's no
|
||||||
// high-level way to express this. Instead, just list a bunch of
|
// high-level way to express this. Instead, just list a bunch of
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include "llvm/Analysis/EHPersonalities.h"
|
#include "llvm/Analysis/EHPersonalities.h"
|
||||||
#include "llvm/Analysis/ValueTracking.h"
|
#include "llvm/Analysis/ValueTracking.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionInitializer.h"
|
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
@ -187,19 +186,15 @@ void MMIAddrLabelMapCallbackPtr::allUsesReplacedWith(Value *V2) {
|
|||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
MachineModuleInfo::MachineModuleInfo(const TargetMachine &TM,
|
MachineModuleInfo::MachineModuleInfo(const MCAsmInfo &MAI,
|
||||||
const MCAsmInfo &MAI,
|
|
||||||
const MCRegisterInfo &MRI,
|
const MCRegisterInfo &MRI,
|
||||||
const MCObjectFileInfo *MOFI,
|
const MCObjectFileInfo *MOFI)
|
||||||
MachineFunctionInitializer *MFI)
|
: ImmutablePass(ID), Context(&MAI, &MRI, MOFI, nullptr, false) {
|
||||||
: ImmutablePass(ID), TM(TM), Context(&MAI, &MRI, MOFI, nullptr, false),
|
|
||||||
MFInitializer(MFI) {
|
|
||||||
initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry());
|
initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineModuleInfo::MachineModuleInfo()
|
MachineModuleInfo::MachineModuleInfo()
|
||||||
: ImmutablePass(ID), TM(*((TargetMachine*)nullptr)),
|
: ImmutablePass(ID), Context(nullptr, nullptr, nullptr) {
|
||||||
Context(nullptr, nullptr, nullptr) {
|
|
||||||
llvm_unreachable("This MachineModuleInfo constructor should never be called, "
|
llvm_unreachable("This MachineModuleInfo constructor should never be called, "
|
||||||
"MMI should always be explicitly constructed by "
|
"MMI should always be explicitly constructed by "
|
||||||
"LLVMTargetMachine");
|
"LLVMTargetMachine");
|
||||||
@ -218,7 +213,7 @@ bool MachineModuleInfo::doInitialization(Module &M) {
|
|||||||
DbgInfoAvailable = UsesVAFloatArgument = UsesMorestackAddr = false;
|
DbgInfoAvailable = UsesVAFloatArgument = UsesMorestackAddr = false;
|
||||||
PersonalityTypeCache = EHPersonality::Unknown;
|
PersonalityTypeCache = EHPersonality::Unknown;
|
||||||
AddrLabelSymbols = nullptr;
|
AddrLabelSymbols = nullptr;
|
||||||
TheModule = &M;
|
TheModule = nullptr;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -466,63 +461,3 @@ try_next:;
|
|||||||
FilterIds.push_back(0); // terminator
|
FilterIds.push_back(0); // terminator
|
||||||
return FilterID;
|
return FilterID;
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineFunction &MachineModuleInfo::getMachineFunction(const Function &F) {
|
|
||||||
// Shortcut for the common case where a sequence of MachineFunctionPasses
|
|
||||||
// all query for the same Function.
|
|
||||||
if (LastRequest == &F)
|
|
||||||
return *LastResult;
|
|
||||||
|
|
||||||
auto I = MachineFunctions.insert(
|
|
||||||
std::make_pair(&F, std::unique_ptr<MachineFunction>()));
|
|
||||||
MachineFunction *MF;
|
|
||||||
if (I.second) {
|
|
||||||
// No pre-existing machine function, create a new one.
|
|
||||||
MF = new MachineFunction(&F, TM, NextFnNum++, *this);
|
|
||||||
// Update the set entry.
|
|
||||||
I.first->second.reset(MF);
|
|
||||||
|
|
||||||
if (MFInitializer)
|
|
||||||
if (MFInitializer->initializeMachineFunction(*MF))
|
|
||||||
report_fatal_error("Unable to initialize machine function");
|
|
||||||
} else {
|
|
||||||
MF = I.first->second.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
LastRequest = &F;
|
|
||||||
LastResult = MF;
|
|
||||||
return *MF;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MachineModuleInfo::deleteMachineFunctionFor(Function &F) {
|
|
||||||
MachineFunctions.erase(&F);
|
|
||||||
LastRequest = nullptr;
|
|
||||||
LastResult = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
/// This pass frees the MachineFunction object associated with a Function.
|
|
||||||
class FreeMachineFunction : public FunctionPass {
|
|
||||||
public:
|
|
||||||
static char ID;
|
|
||||||
FreeMachineFunction() : FunctionPass(ID) {}
|
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
|
||||||
AU.addRequired<MachineModuleInfo>();
|
|
||||||
AU.addPreserved<MachineModuleInfo>();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool runOnFunction(Function &F) override {
|
|
||||||
MachineModuleInfo &MMI = getAnalysis<MachineModuleInfo>();
|
|
||||||
MMI.deleteMachineFunctionFor(F);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
char FreeMachineFunction::ID;
|
|
||||||
} // end anonymous namespace
|
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
FunctionPass *createFreeMachineFunctionPass() {
|
|
||||||
return new FreeMachineFunction();
|
|
||||||
}
|
|
||||||
} // end namespace llvm
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "llvm/CodeGen/LivePhysRegs.h"
|
#include "llvm/CodeGen/LivePhysRegs.h"
|
||||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/CodeGen/MachineDominators.h"
|
#include "llvm/CodeGen/MachineDominators.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
||||||
@ -143,10 +144,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
|
AU.addPreserved<MachineFunctionAnalysis>();
|
||||||
|
AU.addRequired<MachineFunctionAnalysis>();
|
||||||
AU.addRequired<MachineDominatorTree>();
|
AU.addRequired<MachineDominatorTree>();
|
||||||
AU.addRequired<MachinePostDominatorTree>();
|
AU.addRequired<MachinePostDominatorTree>();
|
||||||
AU.addRequired<MachineLoopInfo>();
|
AU.addRequired<MachineLoopInfo>();
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform the CFG structurization
|
/// Perform the CFG structurization
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/Analysis/LoopInfo.h"
|
#include "llvm/Analysis/LoopInfo.h"
|
||||||
#include "llvm/Analysis/PostDominators.h"
|
#include "llvm/Analysis/PostDominators.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/Dominators.h"
|
#include "llvm/IR/Dominators.h"
|
||||||
#include "llvm/IR/Function.h"
|
#include "llvm/IR/Function.h"
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/Dominators.h"
|
#include "llvm/IR/Dominators.h"
|
||||||
#include "llvm/IR/Function.h"
|
#include "llvm/IR/Function.h"
|
||||||
@ -59,6 +60,7 @@ namespace {
|
|||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const override {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
AU.addRequired<DominatorTreeWrapperPass>();
|
AU.addRequired<DominatorTreeWrapperPass>();
|
||||||
AU.addPreserved<DominatorTreeWrapperPass>();
|
AU.addPreserved<DominatorTreeWrapperPass>();
|
||||||
|
AU.addPreserved<MachineFunctionAnalysis>();
|
||||||
FunctionPass::getAnalysisUsage(AU);
|
FunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "HexagonTargetMachine.h"
|
#include "HexagonTargetMachine.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/CodeGen/LiveVariables.h"
|
#include "llvm/CodeGen/LiveVariables.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/StackProtector.h"
|
#include "llvm/CodeGen/StackProtector.h"
|
||||||
#include "llvm/IR/Function.h"
|
#include "llvm/IR/Function.h"
|
||||||
#include "llvm/IR/Instructions.h"
|
#include "llvm/IR/Instructions.h"
|
||||||
@ -42,6 +43,8 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
|
AU.addRequired<MachineFunctionAnalysis>();
|
||||||
|
AU.addPreserved<MachineFunctionAnalysis>();
|
||||||
AU.addPreserved<StackProtector>();
|
AU.addPreserved<StackProtector>();
|
||||||
FunctionPass::getAnalysisUsage(AU);
|
FunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "HexagonVLIWPacketizer.h"
|
#include "HexagonVLIWPacketizer.h"
|
||||||
#include "llvm/Analysis/AliasAnalysis.h"
|
#include "llvm/Analysis/AliasAnalysis.h"
|
||||||
#include "llvm/CodeGen/MachineDominators.h"
|
#include "llvm/CodeGen/MachineDominators.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/MachineLoopInfo.h"
|
#include "llvm/CodeGen/MachineLoopInfo.h"
|
||||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "NVPTXAllocaHoisting.h"
|
#include "NVPTXAllocaHoisting.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/StackProtector.h"
|
#include "llvm/CodeGen/StackProtector.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/Function.h"
|
#include "llvm/IR/Function.h"
|
||||||
@ -27,6 +28,7 @@ public:
|
|||||||
NVPTXAllocaHoisting() : FunctionPass(ID) {}
|
NVPTXAllocaHoisting() : FunctionPass(ID) {}
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
|
AU.addPreserved<MachineFunctionAnalysis>();
|
||||||
AU.addPreserved<StackProtector>();
|
AU.addPreserved<StackProtector>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "NVPTX.h"
|
#include "NVPTX.h"
|
||||||
#include "MCTargetDesc/NVPTXBaseInfo.h"
|
#include "MCTargetDesc/NVPTXBaseInfo.h"
|
||||||
#include "NVPTXUtilities.h"
|
#include "NVPTXUtilities.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/ValueTypes.h"
|
#include "llvm/CodeGen/ValueTypes.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "NVPTXLowerAggrCopies.h"
|
#include "NVPTXLowerAggrCopies.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/StackProtector.h"
|
#include "llvm/CodeGen/StackProtector.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
@ -40,6 +41,7 @@ struct NVPTXLowerAggrCopies : public FunctionPass {
|
|||||||
NVPTXLowerAggrCopies() : FunctionPass(ID) {}
|
NVPTXLowerAggrCopies() : FunctionPass(ID) {}
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
|
AU.addPreserved<MachineFunctionAnalysis>();
|
||||||
AU.addPreserved<StackProtector>();
|
AU.addPreserved<StackProtector>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "NVPTXTargetTransformInfo.h"
|
#include "NVPTXTargetTransformInfo.h"
|
||||||
#include "llvm/Analysis/Passes.h"
|
#include "llvm/Analysis/Passes.h"
|
||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
#include "llvm/CodeGen/Passes.h"
|
#include "llvm/CodeGen/Passes.h"
|
||||||
#include "llvm/CodeGen/TargetPassConfig.h"
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
; STOP: -loop-reduce
|
; STOP: -loop-reduce
|
||||||
; STOP: Loop Strength Reduction
|
; STOP: Loop Strength Reduction
|
||||||
|
; STOP-NEXT: Machine Function Analysis
|
||||||
; STOP-NEXT: MIR Printing Pass
|
; STOP-NEXT: MIR Printing Pass
|
||||||
|
|
||||||
; START: -machine-branch-prob -pre-isel-intrinsic-lowering
|
; START: -machine-branch-prob -pre-isel-intrinsic-lowering
|
||||||
|
@ -17,7 +17,7 @@ entry:
|
|||||||
|
|
||||||
; This must use movl of the stub, not an lea, since the function isn't being
|
; This must use movl of the stub, not an lea, since the function isn't being
|
||||||
; emitted here.
|
; emitted here.
|
||||||
; CHECK: movl L__ZNSbIcED1Ev$non_lazy_ptr-L0$pb(
|
; CHECK: movl L__ZNSbIcED1Ev$non_lazy_ptr-L1$pb(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -450,7 +450,8 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
|||||||
LLVMTargetMachine &LLVMTM = static_cast<LLVMTargetMachine&>(*Target);
|
LLVMTargetMachine &LLVMTM = static_cast<LLVMTargetMachine&>(*Target);
|
||||||
TargetPassConfig &TPC = *LLVMTM.createPassConfig(PM);
|
TargetPassConfig &TPC = *LLVMTM.createPassConfig(PM);
|
||||||
PM.add(&TPC);
|
PM.add(&TPC);
|
||||||
LLVMTM.addMachineModuleInfo(PM, MIR.get());
|
LLVMTM.addMachineModuleInfo(PM);
|
||||||
|
LLVMTM.addMachineFunctionAnalysis(PM, MIR.get());
|
||||||
TPC.printAndVerify("");
|
TPC.printAndVerify("");
|
||||||
|
|
||||||
for (const std::string &RunPassName : *RunPassNames) {
|
for (const std::string &RunPassName : *RunPassNames) {
|
||||||
|
@ -70,7 +70,8 @@ std::unique_ptr<Module> parseMIR(LLVMContext &Context,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const LLVMTargetMachine &LLVMTM = static_cast<const LLVMTargetMachine&>(TM);
|
const LLVMTargetMachine &LLVMTM = static_cast<const LLVMTargetMachine&>(TM);
|
||||||
LLVMTM.addMachineModuleInfo(PM, MIR.get());
|
LLVMTM.addMachineModuleInfo(PM);
|
||||||
|
LLVMTM.addMachineFunctionAnalysis(PM, MIR.get());
|
||||||
|
|
||||||
return M;
|
return M;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user