MCAtom extending methods need to extend the range of the atom as well.
authorOwen Anderson <resistor@mac.com>
Mon, 10 Oct 2011 18:09:38 +0000 (18:09 +0000)
committerOwen Anderson <resistor@mac.com>
Mon, 10 Oct 2011 18:09:38 +0000 (18:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141557 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAtom.h
lib/MC/MCAtom.cpp

index 6805c39756c2575e7bf640012b4e9170c8adc9bc..682cf7cd76c686dfc14225923466dd7521c0b49d 100644 (file)
@@ -49,15 +49,8 @@ public:
   bool isTextAtom() { return Type == TextAtom; }
   bool isDataAtom() { return Type == DataAtom; }
 
-  void addInst(const MCInst &I, uint64_t Address) {
-    assert(Type == TextAtom && "Trying to add MCInst to a non-text atom!");
-    Text.push_back(std::make_pair(Address, I));
-  }
-
-  void addData(const MCData &D) {
-    assert(Type == DataAtom && "Trying to add MCData to a non-data atom!");
-    Data.push_back(D);
-  }
+  void addInst(const MCInst &I, uint64_t Address, unsigned Size);
+  void addData(const MCData &D);
 
   /// split - Splits the atom in two at a given address, which must align with
   /// and instruction boundary if this is a TextAtom.  Returns the newly created
index cd7dbf334b0fe35ac3e97f1ace9240f39532ccdf..d71444324f3d8bff6181bba72a06e8c3e10e2209 100644 (file)
 
 using namespace llvm;
 
+void MCAtom::addInst(const MCInst &I, uint64_t Address, unsigned Size) {
+  assert(Type == TextAtom && "Trying to add MCInst to a non-text atom!");
+
+  assert(Address < End+Size &&
+         "Instruction not contiguous with end of atom!");
+  if (Address > End)
+    Parent->remap(this, Begin, End+Size);
+
+  Text.push_back(std::make_pair(Address, I));
+}
+
+void MCAtom::addData(const MCData &D) {
+  assert(Type == DataAtom && "Trying to add MCData to a non-data atom!");
+  Parent->remap(this, Begin, End+1);
+
+  Data.push_back(D);
+}
+
 MCAtom *MCAtom::split(uint64_t SplitPt) {
   assert((SplitPt > Begin && SplitPt <= End) &&
          "Splitting at point not contained in atom!");