[llvm] acc0224 - [MC] Remove an unneeded special case from MCObjectStreamer::flushPendingLabels

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 15 13:52:24 PDT 2023


Author: Fangrui Song
Date: 2023-06-15T13:52:20-07:00
New Revision: acc0224104fcca51d4059ce3abb787ecdda95d70

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

LOG: [MC] Remove an unneeded special case from MCObjectStreamer::flushPendingLabels

We always pass a non-null F to flushPendingLabels. Wait a bit before changing
the parameter to use a reference.

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCObjectStreamer.h
    llvm/lib/MC/MCObjectStreamer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h
index bd75c357ea378..865b914f88c9b 100644
--- a/llvm/include/llvm/MC/MCObjectStreamer.h
+++ b/llvm/include/llvm/MC/MCObjectStreamer.h
@@ -113,9 +113,9 @@ class MCObjectStreamer : public MCStreamer {
   void addPendingLabel(MCSymbol* label);
 
   /// If any labels have been emitted but not assigned fragments in the current
-  /// Section and Subsection, ensure that they get assigned, either to fragment
-  /// F if possible or to a new data fragment. Optionally, one can provide an
-  /// offset \p FOffset as a symbol offset within the fragment.
+  /// Section and Subsection, ensure that they get assigned to fragment F.
+  /// Optionally, one can provide an offset \p FOffset as a symbol offset within
+  /// the fragment.
   void flushPendingLabels(MCFragment *F, uint64_t FOffset = 0);
 
 public:

diff  --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 958ec48b94344..ea9c1f174197b 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -68,6 +68,7 @@ void MCObjectStreamer::addPendingLabel(MCSymbol* S) {
 }
 
 void MCObjectStreamer::flushPendingLabels(MCFragment *F, uint64_t FOffset) {
+  assert(F);
   MCSection *CurSection = getCurrentSectionOnly();
   if (!CurSection) {
     assert(PendingLabels.empty());
@@ -80,12 +81,8 @@ void MCObjectStreamer::flushPendingLabels(MCFragment *F, uint64_t FOffset) {
     PendingLabels.clear();
   }
 
-  // Associate a fragment with this label, either the supplied fragment
-  // or an empty data fragment.
-  if (F)
-    CurSection->flushPendingLabels(F, FOffset, CurSubsectionIdx);
-  else
-    CurSection->flushPendingLabels(nullptr, 0, CurSubsectionIdx);
+  // Associate the labels with F.
+  CurSection->flushPendingLabels(F, FOffset, CurSubsectionIdx);
 }
 
 void MCObjectStreamer::flushPendingLabels() {


        


More information about the llvm-commits mailing list