From 7dac32d07d54231ba203f7c32f3a9f8e6730810f Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:27:55 +0000 Subject: MC CFG: Keep pointer to parent MCModule in created MCFunctions. Also, drive-by cleaning around createFunction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188875 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCModule.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/llvm/MC/MCModule.h') diff --git a/include/llvm/MC/MCModule.h b/include/llvm/MC/MCModule.h index 02f8ca05b4..6d493628b7 100644 --- a/include/llvm/MC/MCModule.h +++ b/include/llvm/MC/MCModule.h @@ -23,6 +23,7 @@ namespace llvm { class MCAtom; +class MCBasicBlock; class MCDataAtom; class MCFunction; class MCObjectDisassembler; @@ -88,8 +89,8 @@ public: atom_iterator atom_end() { return Atoms.end(); } /// @} - /// \name Create a new MCFunction. - MCFunction *createFunction(const StringRef &Name); + /// \brief Create a new MCFunction. + MCFunction *createFunction(StringRef Name); /// \name Access to the owned function list. /// @{ -- cgit v1.2.3 From 07e8f8f64308239ba9f707c869e0f0e53071a992 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:02 +0000 Subject: MC CFG: Add entrypoint address to MCModule. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188877 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCModule.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include/llvm/MC/MCModule.h') diff --git a/include/llvm/MC/MCModule.h b/include/llvm/MC/MCModule.h index 6d493628b7..a145653af7 100644 --- a/include/llvm/MC/MCModule.h +++ b/include/llvm/MC/MCModule.h @@ -60,14 +60,17 @@ class MCModule { FunctionListTy Functions; /// @} + /// The address of the entrypoint function. + uint64_t Entrypoint; + MCModule (const MCModule &) LLVM_DELETED_FUNCTION; MCModule& operator=(const MCModule &) LLVM_DELETED_FUNCTION; // MCObjectDisassembler creates MCModules. friend class MCObjectDisassembler; - MCModule() : Atoms() { } public: + MCModule() : Entrypoint(0) { } ~MCModule(); /// \name Create a new MCAtom covering the specified offset range. @@ -101,6 +104,9 @@ public: const_func_iterator func_end() const { return Functions.end(); } func_iterator func_end() { return Functions.end(); } /// @} + + /// \brief Get the address of the entrypoint function, or 0 if there is none. + uint64_t getEntrypoint() const { return Entrypoint; } }; } -- cgit v1.2.3 From 46d353f8e8a2bbe02e8aa6a2292eae930dd3b7e6 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:17 +0000 Subject: MC CFG: Add a few needed methods, mainly MCModule::findFirstAtomAfter. While there, do some minor cleanup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188880 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCModule.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/llvm/MC/MCModule.h') diff --git a/include/llvm/MC/MCModule.h b/include/llvm/MC/MCModule.h index a145653af7..c0c242c21a 100644 --- a/include/llvm/MC/MCModule.h +++ b/include/llvm/MC/MCModule.h @@ -43,7 +43,9 @@ class MCModule { typedef std::vector AtomListTy; AtomListTy Atoms; + // For access to map/remap. friend class MCAtom; + /// \brief Remap \p Atom to the given range, and update its Begin/End fields. /// \param Atom An atom belonging to this module. /// An atom should always use this method to update its bounds, because this @@ -83,6 +85,8 @@ public: /// @{ const MCAtom *findAtomContaining(uint64_t Addr) const; MCAtom *findAtomContaining(uint64_t Addr); + const MCAtom *findFirstAtomAfter(uint64_t Addr) const; + MCAtom *findFirstAtomAfter(uint64_t Addr); typedef AtomListTy::const_iterator const_atom_iterator; typedef AtomListTy:: iterator atom_iterator; -- cgit v1.2.3 From aeb2bbcb6d4f13d0032d57fd1cb1a92da2acd01e Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:24 +0000 Subject: MC CFG: Split MCBasicBlocks to mirror atom splitting. When an MCTextAtom is split, all MCBasicBlocks backed by it are automatically split, with a fallthrough between both blocks, and the successors moved to the second block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188881 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCModule.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/llvm/MC/MCModule.h') diff --git a/include/llvm/MC/MCModule.h b/include/llvm/MC/MCModule.h index c0c242c21a..63635c7478 100644 --- a/include/llvm/MC/MCModule.h +++ b/include/llvm/MC/MCModule.h @@ -56,6 +56,21 @@ class MCModule { void map(MCAtom *NewAtom); /// @} + /// \name Basic block tracking + /// @{ + typedef std::vector BBsByAtomTy; + BBsByAtomTy BBsByAtom; + + // For access to basic block > atom tracking. + friend class MCBasicBlock; + friend class MCTextAtom; + + /// \brief Keep track of \p BBBackedByAtom as being backed by \p Atom. + /// This is used to update succs/preds when \p Atom is split. + void trackBBForAtom(const MCTextAtom *Atom, MCBasicBlock *BBBackedByAtom); + void splitBasicBlocksForAtom(const MCTextAtom *TA, const MCTextAtom *NewTA); + /// @} + /// \name Function tracking /// @{ typedef std::vector FunctionListTy; -- cgit v1.2.3