[llvm] 36cadb6 - MCAssembler: Simplify getSectionAddressSize

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 23 18:51:52 PDT 2025


Author: Fangrui Song
Date: 2025-08-23T18:51:47-07:00
New Revision: 36cadb613a2b2af30b2f87acf05d1d96aaf6403e

URL: https://github.com/llvm/llvm-project/commit/36cadb613a2b2af30b2f87acf05d1d96aaf6403e
DIFF: https://github.com/llvm/llvm-project/commit/36cadb613a2b2af30b2f87acf05d1d96aaf6403e.diff

LOG: MCAssembler: Simplify getSectionAddressSize

The tail fragment must be of type FT_Data. Reduce a computeFragmentSize
use.

Added: 
    

Modified: 
    llvm/lib/MC/MCAssembler.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index d172ad170a4d5..0012590daf5a2 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -353,10 +353,9 @@ const MCSymbol *MCAssembler::getBaseSymbol(const MCSymbol &Symbol) const {
 }
 
 uint64_t MCAssembler::getSectionAddressSize(const MCSection &Sec) const {
-  assert(HasLayout);
-  // The size is the last fragment's end offset.
   const MCFragment &F = *Sec.curFragList()->Tail;
-  return getFragmentOffset(F) + computeFragmentSize(F);
+  assert(HasLayout && F.getKind() == MCFragment::FT_Data);
+  return getFragmentOffset(F) + F.getSize();
 }
 
 uint64_t MCAssembler::getSectionFileSize(const MCSection &Sec) const {


        


More information about the llvm-commits mailing list