Skip to content

Commit aa96e20

Browse files
committed
MCSymbol: Remove AMDGPU-specific Kind::TargetCommon
The SymContentsTargetCommon kind introduced by https://reviews.llvm.org/D61493 lackes significant and should be treated as a regular common symbol with a different section index. Update ELFObjectWriter to respect the specified section index. The new representation also works with Hexagon's SHN_HEXAGON_SCOMMON.
1 parent 190778a commit aa96e20

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

llvm/include/llvm/MC/MCSymbol.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class MCSymbol {
4646
Regular,
4747
Equated,
4848
Common,
49-
TargetCommon, // Index stores the section index
5049
};
5150

5251
// Special sentinel value for the absolute pseudo fragment.
@@ -315,7 +314,7 @@ class MCSymbol {
315314
void setCommon(uint64_t Size, Align Alignment, bool Target = false) {
316315
assert(getOffset() == 0);
317316
CommonSize = Size;
318-
kind = Target ? Kind::TargetCommon : Kind::Common;
317+
kind = Kind::Common;
319318

320319
unsigned Log2Align = encode(Alignment);
321320
assert(Log2Align < (1U << NumCommonAlignmentBits) &&
@@ -338,22 +337,15 @@ class MCSymbol {
338337
bool declareCommon(uint64_t Size, Align Alignment, bool Target = false) {
339338
assert(isCommon() || getOffset() == 0);
340339
if(isCommon()) {
341-
if (CommonSize != Size || getCommonAlignment() != Alignment ||
342-
isTargetCommon() != Target)
340+
if (CommonSize != Size || getCommonAlignment() != Alignment)
343341
return true;
344342
} else
345343
setCommon(Size, Alignment, Target);
346344
return false;
347345
}
348346

349347
/// Is this a 'common' symbol.
350-
bool isCommon() const {
351-
return kind == Kind::Common || kind == Kind::TargetCommon;
352-
}
353-
354-
/// Used by AMDGPU to indicate a common-like symbol of section index
355-
/// SHN_AMDGPU_LDS.
356-
bool isTargetCommon() const { return kind == Kind::TargetCommon; }
348+
bool isCommon() const { return kind == Kind::Common; }
357349

358350
MCFragment *getFragment() const {
359351
if (Fragment || !isVariable() || isWeakExternal())

llvm/lib/MC/ELFObjectWriter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,12 @@ void ELFWriter::computeSymbolTable(const RevGroupMapTy &RevGroupMap) {
541541
if (Symbol.isAbsolute()) {
542542
MSD.SectionIndex = ELF::SHN_ABS;
543543
} else if (Symbol.isCommon()) {
544-
if (Symbol.isTargetCommon()) {
545-
MSD.SectionIndex = Symbol.getIndex();
546-
} else {
544+
auto Shndx = Symbol.getIndex();
545+
if (!Shndx) {
547546
assert(!Local);
548-
MSD.SectionIndex = ELF::SHN_COMMON;
547+
Shndx = ELF::SHN_COMMON;
549548
}
549+
MSD.SectionIndex = Shndx;
550550
} else if (Symbol.isUndefined()) {
551551
if (Symbol.isSignature() && !Symbol.isUsedInReloc()) {
552552
MSD.SectionIndex = RevGroupMap.lookup(&Symbol);

0 commit comments

Comments
 (0)