@@ -298,8 +298,8 @@ class MCFragment {
298298// / data.
299299class MCEncodedFragment : public MCFragment {
300300 uint8_t BundlePadding = 0 ;
301- uint32_t ContentStart = 0 ;
302- uint32_t ContentEnd = 0 ;
301+ uint32_t ContentSize = 0 ;
302+ uint64_t ContentStart = 0 ;
303303 uint32_t FixupStart = 0 ;
304304 uint32_t FixupEnd = 0 ;
305305
@@ -360,22 +360,23 @@ class MCEncodedFragment : public MCFragment {
360360
361361 // Content-related functions manage parent's storage using ContentStart and
362362 // ContentSize.
363- void clearContents () { ContentEnd = ContentStart ; }
363+ void clearContents () { ContentSize = 0 ; }
364364 // Get a SmallVector reference. The caller should call doneAppending to update
365- // `ContentEnd `.
365+ // `ContentSize `.
366366 SmallVectorImpl<char > &getContentsForAppending () {
367367 SmallVectorImpl<char > &S = getParent ()->ContentStorage ;
368- if (LLVM_UNLIKELY (ContentEnd != S.size ())) {
368+ if (LLVM_UNLIKELY (ContentStart + ContentSize != S.size ())) {
369369 // Move the elements to the end. Reserve space to avoid invalidating
370370 // S.begin()+I for `append`.
371- auto Size = ContentEnd - ContentStart;
372371 auto I = std::exchange (ContentStart, S.size ());
373- S.reserve (S.size () + Size );
374- S.append (S.begin () + I, S.begin () + I + Size );
372+ S.reserve (S.size () + ContentSize );
373+ S.append (S.begin () + I, S.begin () + I + ContentSize );
375374 }
376375 return S;
377376 }
378- void doneAppending () { ContentEnd = getParent ()->ContentStorage .size (); }
377+ void doneAppending () {
378+ ContentSize = getParent ()->ContentStorage .size () - ContentStart;
379+ }
379380 void appendContents (ArrayRef<char > Contents) {
380381 getContentsForAppending ().append (Contents.begin (), Contents.end ());
381382 doneAppending ();
@@ -387,11 +388,11 @@ class MCEncodedFragment : public MCFragment {
387388 LLVM_ABI void setContents (ArrayRef<char > Contents);
388389 MutableArrayRef<char > getContents () {
389390 return MutableArrayRef (getParent ()->ContentStorage )
390- .slice (ContentStart, ContentEnd - ContentStart );
391+ .slice (ContentStart, ContentSize );
391392 }
392393 ArrayRef<char > getContents () const {
393394 return ArrayRef (getParent ()->ContentStorage )
394- .slice (ContentStart, ContentEnd - ContentStart );
395+ .slice (ContentStart, ContentSize );
395396 }
396397
397398 // Fixup-related functions manage parent's storage using FixupStart and
@@ -409,7 +410,7 @@ class MCEncodedFragment : public MCFragment {
409410 .slice (FixupStart, FixupEnd - FixupStart);
410411 }
411412
412- size_t getSize () const { return ContentEnd - ContentStart ; }
413+ size_t getSize () const { return ContentSize ; }
413414};
414415
415416// / Fragment for data and encoded instructions.
0 commit comments