diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index 9399d56b76f..44cab9e9e3f 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -19,11 +19,11 @@ #include namespace llvm { + class MachineFunction; // ilist_traits template <> -class ilist_traits -{ +class ilist_traits { // this is only set by the MachineBasicBlock owning the ilist friend class MachineBasicBlock; MachineBasicBlock* parent; @@ -70,7 +70,11 @@ public: /// corresponded to originally. /// const BasicBlock *getBasicBlock() const { return BB; } - + + /// getParent - Return the MachineFunction containing this basic block. + /// + const MachineFunction *getParent() const; + typedef ilist::iterator iterator; typedef ilist::const_iterator const_iterator; typedef std::reverse_iterator const_reverse_iterator; diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 93606931868..9d65453edff 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -12,15 +12,19 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineBasicBlock.h" - #include "llvm/BasicBlock.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" #include "Support/LeakDetector.h" -#include - using namespace llvm; +const MachineFunction *MachineBasicBlock::getParent() const { + // Get the parent by getting the Function parent of the basic block, and + // getting the MachineFunction from it. + return &MachineFunction::get(getBasicBlock()->getParent()); +} + + MachineInstr* ilist_traits::createNode() { MachineInstr* dummy = new MachineInstr(0, 0);