Skip to content

Commit 7c53192

Browse files
committed
[COFF] Preserve UniqueID used to create MCSectionCOFF
This UniqueID can be used later to create associative section. e.g. A .pseudo_probe associated to the section of the corresponding function.
1 parent ad599c2 commit 7c53192

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

llvm/include/llvm/MC/MCSectionCOFF.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,19 @@ class MCSectionCOFF final : public MCSection {
4747
/// section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0
4848
mutable int Selection;
4949

50+
unsigned UniqueID;
51+
5052
private:
5153
friend class MCContext;
5254
// The storage of Name is owned by MCContext's COFFUniquingMap.
5355
MCSectionCOFF(StringRef Name, unsigned Characteristics,
54-
MCSymbol *COMDATSymbol, int Selection, MCSymbol *Begin)
56+
MCSymbol *COMDATSymbol, int Selection, unsigned UniqueID,
57+
MCSymbol *Begin)
5558
: MCSection(SV_COFF, Name, Characteristics & COFF::IMAGE_SCN_CNT_CODE,
5659
Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA,
5760
Begin),
5861
Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
59-
Selection(Selection) {
62+
Selection(Selection), UniqueID(UniqueID) {
6063
assert((Characteristics & 0x00F00000) == 0 &&
6164
"alignment must not be set upon section creation");
6265
}
@@ -72,6 +75,8 @@ class MCSectionCOFF final : public MCSection {
7275

7376
void setSelection(int Selection) const;
7477

78+
unsigned getUniqueID() const { return UniqueID; }
79+
7580
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
7681
raw_ostream &OS,
7782
uint32_t Subsection) const override;

llvm/lib/MC/MCContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
718718
StringRef CachedName = Iter->first.SectionName;
719719
MCSymbol *Begin = getOrCreateSectionSymbol<MCSymbolCOFF>(Section);
720720
MCSectionCOFF *Result = new (COFFAllocator.Allocate()) MCSectionCOFF(
721-
CachedName, Characteristics, COMDATSymbol, Selection, Begin);
721+
CachedName, Characteristics, COMDATSymbol, Selection, UniqueID, Begin);
722722
Iter->second = Result;
723723
auto *F = allocInitialFragment(*Result);
724724
Begin->setFragment(F);

0 commit comments

Comments
 (0)