Skip to content

Commit f6dcd2a

Browse files
committed
Convert BindingExplicitlySet into a MCSymbolELF field.
I will pack it better in a followup patch. llvm-svn: 238975
1 parent d595733 commit f6dcd2a

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

llvm/include/llvm/MC/MCELFStreamer.h

-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class MCELFStreamer : public MCObjectStreamer {
3737
void reset() override {
3838
SeenIdent = false;
3939
LocalCommons.clear();
40-
BindingExplicitlySet.clear();
4140
BundleGroups.clear();
4241
MCObjectStreamer::reset();
4342
}
@@ -106,8 +105,6 @@ class MCELFStreamer : public MCObjectStreamer {
106105

107106
std::vector<LocalCommon> LocalCommons;
108107

109-
SmallPtrSet<MCSymbol *, 16> BindingExplicitlySet;
110-
111108
/// BundleGroups - The stack of fragments holding the bundle-locked
112109
/// instructions.
113110
llvm::SmallVector<MCDataFragment *, 4> BundleGroups;

llvm/include/llvm/MC/MCSymbolELF.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ class MCSymbolELF : public MCSymbol {
1717
/// symbol has no size this field will be NULL.
1818
const MCExpr *SymbolSize = nullptr;
1919

20+
mutable unsigned BindingSet : 1;
21+
2022
public:
2123
MCSymbolELF(const StringMapEntry<bool> *Name, bool isTemporary)
22-
: MCSymbol(true, Name, isTemporary) {}
24+
: MCSymbol(true, Name, isTemporary), BindingSet(false) {}
2325
void setSize(const MCExpr *SS) { SymbolSize = SS; }
2426

2527
const MCExpr *getSize() const { return SymbolSize; }
@@ -36,6 +38,8 @@ class MCSymbolELF : public MCSymbol {
3638
void setBinding(unsigned Binding) const;
3739
unsigned getBinding() const;
3840

41+
bool isBindingSet() const { return BindingSet; }
42+
3943
static bool classof(const MCSymbol *S) { return S->isELF(); }
4044
};
4145
}

llvm/lib/MC/MCELFStreamer.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -241,26 +241,22 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
241241
Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
242242
Symbol->setBinding(ELF::STB_GNU_UNIQUE);
243243
Symbol->setExternal(true);
244-
BindingExplicitlySet.insert(Symbol);
245244
break;
246245

247246
case MCSA_Global:
248247
Symbol->setBinding(ELF::STB_GLOBAL);
249248
Symbol->setExternal(true);
250-
BindingExplicitlySet.insert(Symbol);
251249
break;
252250

253251
case MCSA_WeakReference:
254252
case MCSA_Weak:
255253
Symbol->setBinding(ELF::STB_WEAK);
256254
Symbol->setExternal(true);
257-
BindingExplicitlySet.insert(Symbol);
258255
break;
259256

260257
case MCSA_Local:
261258
Symbol->setBinding(ELF::STB_LOCAL);
262259
Symbol->setExternal(false);
263-
BindingExplicitlySet.insert(Symbol);
264260
break;
265261

266262
case MCSA_ELF_TypeFunction:
@@ -309,7 +305,7 @@ void MCELFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size,
309305
auto *Symbol = cast<MCSymbolELF>(S);
310306
getAssembler().registerSymbol(*Symbol);
311307

312-
if (!BindingExplicitlySet.count(Symbol)) {
308+
if (!Symbol->isBindingSet()) {
313309
Symbol->setBinding(ELF::STB_GLOBAL);
314310
Symbol->setExternal(true);
315311
}
@@ -343,7 +339,6 @@ void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *S, uint64_t Size,
343339
getAssembler().registerSymbol(*Symbol);
344340
Symbol->setBinding(ELF::STB_LOCAL);
345341
Symbol->setExternal(false);
346-
BindingExplicitlySet.insert(Symbol);
347342
EmitCommonSymbol(Symbol, Size, ByteAlignment);
348343
}
349344

llvm/lib/MC/MCSymbolELF.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
namespace llvm {
1717

1818
void MCSymbolELF::setBinding(unsigned Binding) const {
19+
BindingSet = true;
1920
assert(Binding == ELF::STB_LOCAL || Binding == ELF::STB_GLOBAL ||
2021
Binding == ELF::STB_WEAK || Binding == ELF::STB_GNU_UNIQUE);
2122
uint32_t OtherFlags = getFlags() & ~(0xf << ELF_STB_Shift);

0 commit comments

Comments
 (0)