[MC] registerSymbol: change an output paramter to return value
authorFangrui Song <i@maskray.me>
Fri, 5 May 2023 05:17:56 +0000 (22:17 -0700)
committerFangrui Song <i@maskray.me>
Fri, 5 May 2023 05:17:56 +0000 (22:17 -0700)
llvm/include/llvm/MC/MCAssembler.h
llvm/lib/MC/MCAssembler.cpp
llvm/lib/MC/MCMachOStreamer.cpp
llvm/lib/MC/MCWinCOFFStreamer.cpp
llvm/lib/MC/MachObjectWriter.cpp

index 80aa97c..5e1fc73 100644 (file)
@@ -473,8 +473,7 @@ public:
   /// @{
 
   bool registerSection(MCSection &Section);
-
-  void registerSymbol(const MCSymbol &Symbol, bool *Created = nullptr);
+  bool registerSymbol(const MCSymbol &Symbol);
 
   MutableArrayRef<std::pair<std::string, size_t>> getFileNames() {
     return FileNames;
index 179fe23..159b6a8 100644 (file)
@@ -464,14 +464,13 @@ void MCAsmLayout::layoutFragment(MCFragment *F) {
   }
 }
 
-void MCAssembler::registerSymbol(const MCSymbol &Symbol, bool *Created) {
-  bool New = !Symbol.isRegistered();
-  if (Created)
-    *Created = New;
-  if (New) {
+bool MCAssembler::registerSymbol(const MCSymbol &Symbol) {
+  bool Changed = !Symbol.isRegistered();
+  if (Changed) {
     Symbol.setIsRegistered(true);
     Symbols.push_back(&Symbol);
   }
+  return Changed;
 }
 
 void MCAssembler::writeFragmentPadding(raw_ostream &OS,
index 986c0c2..82cfcc3 100644 (file)
@@ -534,9 +534,7 @@ void MCMachOStreamer::finishImpl() {
 
 void MCMachOStreamer::finalizeCGProfileEntry(const MCSymbolRefExpr *&SRE) {
   const MCSymbol *S = &SRE->getSymbol();
-  bool Created;
-  getAssembler().registerSymbol(*S, &Created);
-  if (Created)
+  if (getAssembler().registerSymbol(*S))
     S->setExternal(true);
 }
 
index c9a9681..36b29b7 100644 (file)
@@ -344,9 +344,7 @@ void MCWinCOFFStreamer::emitCGProfileEntry(const MCSymbolRefExpr *From,
 
 void MCWinCOFFStreamer::finalizeCGProfileEntry(const MCSymbolRefExpr *&SRE) {
   const MCSymbol *S = &SRE->getSymbol();
-  bool Created;
-  getAssembler().registerSymbol(*S, &Created);
-  if (Created)
+  if (getAssembler().registerSymbol(*S))
     cast<MCSymbolCOFF>(S)->setExternal(true);
 }
 
index 446d137..6b263df 100644 (file)
@@ -531,9 +531,7 @@ void MachObjectWriter::bindIndirectSymbols(MCAssembler &Asm) {
     // Set the symbol type to undefined lazy, but only on construction.
     //
     // FIXME: Do not hardcode.
-    bool Created;
-    Asm.registerSymbol(*it->Symbol, &Created);
-    if (Created)
+    if (Asm.registerSymbol(*it->Symbol))
       cast<MCSymbolMachO>(it->Symbol)->setReferenceTypeUndefinedLazy(true);
   }
 }