[llvm] 01260bb - [MC] registerSymbol: change an output paramter to return value
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu May 4 22:18:01 PDT 2023
Author: Fangrui Song
Date: 2023-05-04T22:17:56-07:00
New Revision: 01260bbc6b4efea860fb654a449db20ed0f87451
URL: https://github.com/llvm/llvm-project/commit/01260bbc6b4efea860fb654a449db20ed0f87451
DIFF: https://github.com/llvm/llvm-project/commit/01260bbc6b4efea860fb654a449db20ed0f87451.diff
LOG: [MC] registerSymbol: change an output paramter to return value
Added:
Modified:
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
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h
index 80aa97c315da7..5e1fc738b1dab 100644
--- a/llvm/include/llvm/MC/MCAssembler.h
+++ b/llvm/include/llvm/MC/MCAssembler.h
@@ -473,8 +473,7 @@ class MCAssembler {
/// @{
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;
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 179fe23abc768..159b6a8ffc984 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -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,
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 986c0c2c506bf..82cfcc3ac76cc 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -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);
}
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index c9a9681648341..36b29b792420f 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -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);
}
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 446d1372fa669..6b263df92cbeb 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -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);
}
}
More information about the llvm-commits
mailing list