diff options
author | Gabor Greif <ggreif@gmail.com> | 2009-02-27 08:41:37 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2009-02-27 08:41:37 +0000 |
commit | 0a0e68a7eac0513505aff3079e2d5d6864e51895 (patch) | |
tree | c54400d09f9606629635d0a926cb5999440ca74c /include/llvm/BasicBlock.h | |
parent | 8b3894cdfd9784725ec33755eb270f12b0e74f0f (diff) |
Introduce a new technique for merging BasicBlock with Instruction sentinel by superposition.
This looks dangerous, but isn't because the sentinel is accessed in special way only,
namely the Next and Prev fields of it, and these are guaranteed to exist.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65626 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/BasicBlock.h')
-rw-r--r-- | include/llvm/BasicBlock.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 780aca5ef6..29caa0ab19 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -26,11 +26,15 @@ class TerminatorInst; template<> struct ilist_traits<Instruction> : public SymbolTableListTraits<Instruction, BasicBlock> { // createSentinel is used to create a node that marks the end of the list... - static Instruction *createSentinel(); - static void destroySentinel(Instruction *I) { delete I; } + Instruction *createSentinel() const { + return const_cast<Instruction*>(static_cast<const Instruction*>(&Sentinel)); + } + static void destroySentinel(Instruction *I) { } static iplist<Instruction> &getList(BasicBlock *BB); static ValueSymbolTable *getSymTab(BasicBlock *ItemParent); static int getListOffset(); +private: + ilist_node<Instruction> Sentinel; }; /// This represents a single basic block in LLVM. A basic block is simply a @@ -49,9 +53,10 @@ template<> struct ilist_traits<Instruction> /// @brief LLVM Basic Block Representation class BasicBlock : public Value, // Basic blocks are data objects also public ilist_node<BasicBlock> { + public: typedef iplist<Instruction> InstListType; -private : +private: InstListType InstList; Function *Parent; |