diff options
author | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2013-08-21 07:27:55 +0000 |
---|---|---|
committer | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2013-08-21 07:27:55 +0000 |
commit | 7bfc7da6e87abf8ab77a9a04b0ca355a6713b442 (patch) | |
tree | 8b80f2928e60f85bd76145b73981f5b4da5b8119 /llvm/lib | |
parent | d6351e76d53bfb9d6be9487a394b8a5b75a28e42 (diff) | |
download | bcm5719-llvm-7bfc7da6e87abf8ab77a9a04b0ca355a6713b442.tar.gz bcm5719-llvm-7bfc7da6e87abf8ab77a9a04b0ca355a6713b442.zip |
MC CFG: Keep pointer to parent MCModule in created MCFunctions.
Also, drive-by cleaning around createFunction.
llvm-svn: 188875
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/MC/MCFunction.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/MC/MCModule.cpp | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/MC/MCFunction.cpp b/llvm/lib/MC/MCFunction.cpp index 473d07bf994..cb2504668a3 100644 --- a/llvm/lib/MC/MCFunction.cpp +++ b/llvm/lib/MC/MCFunction.cpp @@ -9,15 +9,15 @@ #include "llvm/MC/MCFunction.h" #include "llvm/MC/MCAtom.h" -#include "llvm/Support/raw_ostream.h" +#include "llvm/MC/MCModule.h" #include <algorithm> using namespace llvm; // MCFunction -MCFunction::MCFunction(StringRef Name) - : Name(Name) +MCFunction::MCFunction(StringRef Name, MCModule *Parent) + : Name(Name), ParentModule(Parent) {} MCFunction::~MCFunction() { diff --git a/llvm/lib/MC/MCModule.cpp b/llvm/lib/MC/MCModule.cpp index 5890b4bd028..9a9d90e5b6a 100644 --- a/llvm/lib/MC/MCModule.cpp +++ b/llvm/lib/MC/MCModule.cpp @@ -54,9 +54,13 @@ void MCModule::remap(MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd) { assert(*I == Atom && "Previous atom mapping was invalid!"); Atoms.erase(I); + // FIXME: special case NewBegin == Atom->Begin + // Insert the new mapping. AtomListTy::iterator NewI = std::lower_bound(atom_begin(), atom_end(), NewBegin, AtomComp); + assert((NewI == atom_end() || (*NewI)->getBeginAddr() > Atom->End) + && "Offset range already occupied!"); Atoms.insert(NewI, Atom); // Update the atom internal bounds. @@ -80,8 +84,8 @@ MCAtom *MCModule::findAtomContaining(uint64_t Addr) { return 0; } -MCFunction *MCModule::createFunction(const StringRef &Name) { - Functions.push_back(new MCFunction(Name)); +MCFunction *MCModule::createFunction(StringRef Name) { + Functions.push_back(new MCFunction(Name, this)); return Functions.back(); } |